Click here to Skip to main content
16,013,440 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Reading data from a file Pin
BaldwinMartin23-Nov-04 10:26
BaldwinMartin23-Nov-04 10:26 
GeneralStatic member funciton call non-static function Pin
Zero_G21-Nov-04 10:32
Zero_G21-Nov-04 10:32 
GeneralRe: Static member funciton call non-static function Pin
bmzhao21-Nov-04 13:57
bmzhao21-Nov-04 13:57 
GeneralRe: Static member funciton call non-static function Pin
Christian Graus21-Nov-04 14:29
protectorChristian Graus21-Nov-04 14:29 
GeneralRe: Static member funciton call non-static function Pin
nguyenvhn21-Nov-04 22:27
nguyenvhn21-Nov-04 22:27 
GeneralRe: Static member funciton call non-static function Pin
Christian Graus21-Nov-04 22:59
protectorChristian Graus21-Nov-04 22:59 
GeneralRe: Static member funciton call non-static function Pin
nguyenvhn21-Nov-04 23:36
nguyenvhn21-Nov-04 23:36 
GeneralRe: Static member funciton call non-static function Pin
Christian Graus21-Nov-04 23:43
protectorChristian Graus21-Nov-04 23:43 
nguyenvhn wrote:
According to C++ principle, static members should be shared with every instances of class

Wrong - a static method is visible to anyone who can see the class scope, even if no instance exists. In C++, it's also visible from the instance scope, although in C# it is not.

nguyenvhn wrote:
But in few case, we need an exception. C++ do not prevent me to implement such that. And here, the guy had a reason to have such case.

We've not even seen his code, or know what he's trying to do. The fact remains, if you need an instance of the class to make the code work, if it needs to call a non static method, then either the other method should be static, or the other method has state, making this method also stateful, and also a method that should not be static.

If a method does not make sense to call when there's no instance of the class, it should not be static, simple as that. Your solution makes it seem static, but it's not, it can't be called without an instance. A design principle of C++ is to allow bad coding, and trust that coders will write good code, so they never have to fight the language. What you propose is possible, that doesn't make it good coding practice.

Christian

I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
GeneralRe: Static member funciton call non-static function Pin
nguyenvhn22-Nov-04 0:25
nguyenvhn22-Nov-04 0:25 
GeneralRe: Static member funciton call non-static function Pin
Steve S22-Nov-04 0:32
Steve S22-Nov-04 0:32 
GeneralTutorial for Visual C++ .NET 2003 Pin
Rylogy21-Nov-04 9:37
Rylogy21-Nov-04 9:37 
QuestionSTL fstream brakedown in VS .NET? Pin
Robert Bielik21-Nov-04 9:08
Robert Bielik21-Nov-04 9:08 
AnswerRe: STL fstream brakedown in VS .NET? Pin
Aamir Butt21-Nov-04 20:34
Aamir Butt21-Nov-04 20:34 
GeneralRe: STL fstream brakedown in VS .NET? Pin
Robert Bielik21-Nov-04 20:42
Robert Bielik21-Nov-04 20:42 
GeneralBits; Pin
Bo Hunter21-Nov-04 8:38
Bo Hunter21-Nov-04 8:38 
GeneralRe: Bits; Pin
Neville Franks21-Nov-04 10:13
Neville Franks21-Nov-04 10:13 
GeneralRe: Bits; Pin
Bo Hunter21-Nov-04 12:17
Bo Hunter21-Nov-04 12:17 
GeneralRe: Bits; Pin
Henry miller22-Nov-04 2:48
Henry miller22-Nov-04 2:48 
QuestionHow to create a bitmap using pixel color information in WindowsCE? Pin
mutpan21-Nov-04 7:52
mutpan21-Nov-04 7:52 
GeneralCreate folder Pin
DanYELL21-Nov-04 5:28
DanYELL21-Nov-04 5:28 
GeneralRe: Create folder Pin
John R. Shaw21-Nov-04 5:52
John R. Shaw21-Nov-04 5:52 
GeneralRe: Create folder Pin
Renjith Ramachandran21-Nov-04 7:56
Renjith Ramachandran21-Nov-04 7:56 
GeneralRe: Create folder Pin
ThatsAlok21-Nov-04 17:32
ThatsAlok21-Nov-04 17:32 
GeneralCapture and CHANGE ip packets Pin
kydfru21-Nov-04 3:22
kydfru21-Nov-04 3:22 
GeneralRe: Capture and CHANGE ip packets Pin
benjymous21-Nov-04 22:50
benjymous21-Nov-04 22:50 

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.