Click here to Skip to main content
16,014,650 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Thanks, How can i launch the DUN entry dialog in vc program Pin
Joaquín M López Muñoz3-Feb-02 21:53
Joaquín M López Muñoz3-Feb-02 21:53 
Generalreversed List Control Pin
Jerome Conus3-Feb-02 19:45
Jerome Conus3-Feb-02 19:45 
GeneralRe: reversed List Control Pin
wangyiming3-Feb-02 20:56
wangyiming3-Feb-02 20:56 
GeneralRe: reversed List Control Pin
Paul M Watt3-Feb-02 21:13
mentorPaul M Watt3-Feb-02 21:13 
GeneralC2084 Pin
3-Feb-02 18:13
suss3-Feb-02 18:13 
GeneralRe: C2084 Pin
Paul M Watt3-Feb-02 18:19
mentorPaul M Watt3-Feb-02 18:19 
GeneralRe: C2084 Pin
marouane miftah el kheir3-Feb-02 18:21
marouane miftah el kheir3-Feb-02 18:21 
GeneralRe: C2084 Pin
Paul M Watt3-Feb-02 19:34
mentorPaul M Watt3-Feb-02 19:34 
There are a number of ways to write a class. I think that how you do it depends on the current situation. Alot of times programming style simply depends on your tastes. I have developed code with alot of other people, and they all like to organize their classes in their own ways. One thing to keep in mind though, is that alot of people may see your header files if they are going to use your classes, the implementation files are rarely ever seen. With this in mind, the code that you do not want other people to see should be placed in the .cpp file.

If you have a large class with complicated implmentations I would create a header file with the class and function declarations, then place the implementations in the .cpp file.

If you class has a lot of simple get and set functions, these are good candidates for inline functions.
For instance:

<br />
class Stock<br />
{<br />
<br />
    CHAR* GetName ()<br />
    {<br />
        return name;<br />
    }<br />
<br />
};<br />


or like I suggested earlier, add the inline declaration to the function implementation.

<br />
class Stock<br />
{<br />
<br />
    CHAR* GetName ();<br />
<br />
};<br />
<br />
inline CHAR* Stock::GetName ()<br />
{<br />
    return name;<br />
}<br />
<br />


inline functions will make the entire piece of code that is created for the function will be compiled inline where the function would normally be called instead of actually calling the function. The only drawbacks to inline functions is that if you do it too often, the size of your program will become bloated. Use function inlining judiciously.

The reason why you get a million errors with out the inline declaration, is because every file that includes your header file recompiles the functions that should be declared inline, and when the linker tries to link all of these files it finds multiple implementations for the function. Using inline forces only one implementation.
Questioncreate a project? Pin
3-Feb-02 17:21
suss3-Feb-02 17:21 
AnswerRe: create a project? Pin
Paul M Watt3-Feb-02 17:41
mentorPaul M Watt3-Feb-02 17:41 
GeneralRe: create a project? Pin
3-Feb-02 17:43
suss3-Feb-02 17:43 
GeneralPointers Pin
Matt Newman3-Feb-02 15:47
Matt Newman3-Feb-02 15:47 
GeneralRe: Pointers Pin
Paul M Watt3-Feb-02 16:06
mentorPaul M Watt3-Feb-02 16:06 
GeneralRe: Pointers Pin
Matt Newman4-Feb-02 11:07
Matt Newman4-Feb-02 11:07 
GeneralRe: Pointers Pin
Matt Newman4-Feb-02 11:35
Matt Newman4-Feb-02 11:35 
GeneralRe: Pointers Pin
Jay Beckert3-Feb-02 16:13
Jay Beckert3-Feb-02 16:13 
GeneralRe: Pointers Pin
Paul M Watt3-Feb-02 16:15
mentorPaul M Watt3-Feb-02 16:15 
GeneralRe: Pointers Pin
Jay Beckert3-Feb-02 16:26
Jay Beckert3-Feb-02 16:26 
GeneralRe: Pointers Pin
Matt Newman3-Feb-02 16:27
Matt Newman3-Feb-02 16:27 
GeneralRe: Pointers Pin
Matt Newman4-Feb-02 11:36
Matt Newman4-Feb-02 11:36 
GeneralRe: Pointers Pin
Jay Beckert5-Feb-02 11:21
Jay Beckert5-Feb-02 11:21 
GeneralRe: Pointers Pin
Matt Newman5-Feb-02 12:43
Matt Newman5-Feb-02 12:43 
GeneralRe: Pointers Pin
Jay Beckert5-Feb-02 13:16
Jay Beckert5-Feb-02 13:16 
General3d rotation Pin
Sergei3-Feb-02 14:49
Sergei3-Feb-02 14:49 
GeneralRe: 3d rotation Pin
Paul M Watt3-Feb-02 15:36
mentorPaul M Watt3-Feb-02 15:36 

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.