Click here to Skip to main content
15,892,298 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Extracting the IStream interface from CFile Pin
Anonymous8-May-03 23:17
Anonymous8-May-03 23:17 
GeneralRe: Extracting the IStream interface from CFile Pin
Mike Dimmick9-May-03 6:05
Mike Dimmick9-May-03 6:05 
GeneralRe: Extracting the IStream interface from CFile Pin
Anders Sandberg13-May-03 0:06
Anders Sandberg13-May-03 0:06 
GeneralPls Help.. CFtpFileFind Pin
2249178-May-03 20:27
2249178-May-03 20:27 
GeneralRe: Pls Help.. CFtpFileFind Pin
Mahesh Varma9-May-03 18:33
Mahesh Varma9-May-03 18:33 
GeneralRe: Pls Help.. CFtpFileFind Pin
22491722-Jan-04 1:12
22491722-Jan-04 1:12 
QuestionWhy use ???::??? Pin
alex.barylski8-May-03 20:21
alex.barylski8-May-03 20:21 
AnswerRe: Why use ???::??? Pin
Joseph Dempsey9-May-03 1:12
Joseph Dempsey9-May-03 1:12 
I think you are not quite understanding why the namespaces are used first of all. They are not to prevent function level name clashes ( well that too ) but also class name clashes. STL has a class called vector and on the off chance you have your own class called vector it doesn't want to clash. a namespace is just a thin scope wrapper around functions and types declare with in. whe you use the mysqlcppai:: all you are doing is specifying directly the scope of the class you want to use. for example lets say you have this code.

class CMyConnection
{
:
};

namespace MYAPI 
{
  class CMyConnection
  {
  :
  };
}

void somefunc()
{
    // which one do you get?  you get the first declaration because you are using "global "scope"
 CMyConnection conn;  

    // now this will get you the second
  MYAPI::CMyConnection conn;

}


It's really just a container for all this stuff. There is a way in all this though to not have to prefix the function or type with the namespace name IF you know there are no classes in the file you're using. For example the stl namespace is std:: and there is a class called vector. To use it without declaring std:: over and over again at the top of your file somehwere you could do a
using namespace std;
Then you wouldn't have to do std:: everywhere. You could just do something like:

int main()
{
  vector v;  // instead of std::vector v;
  :
  :
}


now if you have something to the effect of

#include <stl.h>

class vector 
{
:
};

int main()
{
  vector v;
  :
}


There are two problems. One since the class vector is in the same file you would get a redefinition of type error but even if it was in a different file you would have an ambiguity because there would be two possible types for the same vector. Thats where you would need to use std::vector instead.

Hope this helped. Cheers!!

Joseph Dempsey
joseph_r_dempsey@yahoo.com

"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
AnswerRe: Why use ???::??? Pin
Mike Dimmick9-May-03 6:21
Mike Dimmick9-May-03 6:21 
GeneralSend mail with SMTP Pin
Mazdak8-May-03 19:27
Mazdak8-May-03 19:27 
GeneralRe: Send mail with SMTP Pin
markkuk9-May-03 0:40
markkuk9-May-03 0:40 
GeneralRe: Send mail with SMTP Pin
Mazdak9-May-03 4:48
Mazdak9-May-03 4:48 
GeneralRe: Send mail with SMTP Pin
Anders Molin9-May-03 1:21
professionalAnders Molin9-May-03 1:21 
GeneralRe: Send mail with SMTP Pin
Mazdak9-May-03 4:48
Mazdak9-May-03 4:48 
GeneralAbout using CopyFileEx( ) Pin
charisma_youn8-May-03 18:01
charisma_youn8-May-03 18:01 
GeneralRe: About using CopyFileEx( ) Pin
Neville Franks9-May-03 12:00
Neville Franks9-May-03 12:00 
GeneralINTERNAL COMPILER ERROR Pin
aguest8-May-03 15:29
aguest8-May-03 15:29 
GeneralRe: INTERNAL COMPILER ERROR Pin
Maxwell Chen8-May-03 16:39
Maxwell Chen8-May-03 16:39 
GeneralRe: INTERNAL COMPILER ERROR Pin
jhwurmbach9-May-03 2:05
jhwurmbach9-May-03 2:05 
GeneralRe: INTERNAL COMPILER ERROR Pin
Roger Allen9-May-03 2:20
Roger Allen9-May-03 2:20 
GeneralRe: INTERNAL COMPILER ERROR Pin
Erik Juhl9-May-03 5:25
Erik Juhl9-May-03 5:25 
QuestionCan a window Pin
RuchikaDhingra8-May-03 15:10
RuchikaDhingra8-May-03 15:10 
AnswerRe: Can a window Pin
John R. Shaw8-May-03 16:49
John R. Shaw8-May-03 16:49 
GeneralBackground thread Pin
basementman9-May-03 5:18
basementman9-May-03 5:18 
GeneralRe: Background thread Pin
RuchikaDhingra9-May-03 6:27
RuchikaDhingra9-May-03 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.