Click here to Skip to main content
15,896,063 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: Why use ???::??? Pin
Mike Dimmick9-May-03 6:21
Mike Dimmick9-May-03 6:21 
The C++ symbol "::" is the scope-resolution operator. It tells the compiler to look for the item on the right of the operator inside the scope on the left.

There are two kinds of scopes in C++: classes and namespaces. Your first example uses scope resolution to call the base class's implementation of MyMethod(). When using scope-resolution in this way, it forces the compiler to statically choose the version of the function to call, rather than dynamically (which normally results in a recursive call with this idiom).

Namespaces allow related classes, functions and data to be given a related name. Instead of naming your classes:

mysqlcppapi_Connection

etc, you can name them

mysqlcppapi::Connection

So far, not much benefit. But you can use a shorter name with the using declaration:

using mysqlcppapi::Connection;<br />
<br />
Connection con; // con is a mysqlcppapi::Connection


If you decide to write using directives:

using namespace mysqlcppapi;<br />
using namespace myOtherNamespace;


and a Connection class is declared in both, you will have to revert to indicating which one you mean with the :: operator.

Namespaces have another advantage over using static class members; the declaration of a namespace can be re-opened, that is, you can add members to a namespace in multiple files.

--
Mike Dimmick
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 
GeneralRe: Background thread Pin
John R. Shaw9-May-03 8:19
John R. Shaw9-May-03 8:19 

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.