|
tom76 wrote:
const int MyClass::MEMBER_ONE = 64;
const int MyClass::MEMBER_TWO = 128;
These must appear only once, so move them from the .h to the .cpp that defines the class.
It would also help a lot if you included the specific compiler error and indicated what line it referred to.
tom76 wrote:
static const MyClass MyObj;
This instantiating an instance of the class. Is that what you realy want. I don't know if you can have a const class like this.
Also globals are bad, very bad.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I've not got a definition (.cpp file) for my class, as all I am using it for is to create a static const object with these members so everything is in MyClass.h . I believe I need a global because I only want one instance of this object, because the members will never change value.
The errors are
error C2059: syntax error : 'constant'
error C2238: unexpected token(s) preceding ';'
for each member.
Obseve everything, remember more...
|
|
|
|
|
tom76 wrote:
I believe I need a global because I only want one instance of this object, because the members will never change value.
Would it be better to make your variables (which seem to be constants) constant members of the Application-class? So you can access them (almost) everywhere in your program and yet they are not global.
Example:
Yourapp.h
class CYourapp : CApp
{
[...].public:
const int m_One;
const int m_Two;
[...].}
Yourapp.cpp
[...]
CYourapp::m_One = 1;
CYourapp::m_Two = 2;
[...].
Use in either of this ways:
int i = theApp.m_One;
int j = static_cast<CYourApp*>(AfxGetApp())->m_Two;
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thanks, I'll have a go at that I think. Still don't know why I am getting these syntax errors though. Oh well.
Obseve everything, remember more...
|
|
|
|
|
At first sight, It's a little strange.
'Cause my poor skill
Why const variable have to be a static one?
My wild guess is that a const variable will also have just a one instance between several class instance like a static.
Actually, It's not exactly right.
But I think const and static have similitiy on each other in this case.
Develope yourself
|
|
|
|
|
class MyClass
{
public:
MyClass() : MEMBER_ONE(64), MEMBER_TWO(128){};
~MyClass(){};
public:
const int MEMBER_ONE;
const int MEMBER_TWO;
//... etc.
};
Trust in the code Luke. Yea right!
|
|
|
|
|
I'll try it, thanks.
Obseve everything, remember more...
|
|
|
|
|
I am writing an application which is minimized to the systray and the timer is run. After some time I want a window to appear close to the icon.
My question is how to create a window which will be displayed even when he aplication is minimized.
Please help
|
|
|
|
|
Maybe this article will help,
http://www.codeproject.com/dialog/taskbarnotifier.asp?target=messenger[^]
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Thanks it will really help
|
|
|
|
|
I'm just getting into Visual C++. What books would you recommend reading? or any other resources would be helpful.
Thanks,
BZZR
|
|
|
|
|
Ivor Horton's Beginning Visual C++ 6 is a good start
Le Ridder Noir
Considderd to be the worlds fastest knoppenbonker.
one year of working experience with the worlds fastest copie paster(about 2000 lines a minute).
And experience with the one and only NewEra Guru and Crystal Ace.
|
|
|
|
|
It also depends what type of development you'll be doing with it. If you're going to be using MFC (which is pretty likely) then I can recommend Jeff Prosise's Programming Windows with MFC 2nd ed. But I'd definitely get a book on general C++ programming first, to get the language thing under your belt and sorted first.
--
Paul
"Put the key of despair into the lock of apathy. Turn the knob of mediocrity slowly and open the gates of despondency - welcome to a day in the average office."
- David Brent, from "The Office"
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
I recommend to Introduction to MFC Programming with Visual C++ by Richard M. Jones for beginner Windows programmers.
Kuphryn
|
|
|
|
|
Thanks for the suggestions guys.
Yes, I will be using MFC. If that makes a difference in your suggestions please re-post.
Otherwise, Thanks again.
|
|
|
|
|
Along with any books on programing with MFC, you should look at all the great totorials on this site. As well as those presented at other sites dedicated to programing.
Trust in the code Luke. Yea right!
|
|
|
|
|
I think you should learn a little Win32 before you move on to MFC so you get a better idea of what's going on. Try Charles Petzold: Programming Windows 5th edition. I jumped into Ivor Horton's book at the beginning but was lost with all the pre-made code with MFC so I tried Win32 and I like it so much that I stuck with it.
|
|
|
|
|
Sorry some thing went wacked while I was trying to replay to this. Let's try agian.
You jumped into the wrong thread. I just recommended the totorials on this site and others that are dedicatated to programing as an addition to books recommended by others. As for Charles Petzold, I highly recommend it, since too many of us have gotten tied up in C++/OOP and forgoten the basics upon which it is all founded. C++ and MFC is great (minus the bugs) but it hides all the basic implementations ( aka. how it all works ). There are a few books on my shelf I could have sujested but they are far past what I would recommend to some one new in this area of programming.
As for 'Ivor Horton's' book I have never read it, may be I'll take a look to see if it is worth may time.
FYI: Most Visual C++/MFC Books are a rehash of whats in the MSDN Library.
Trust in the code Luke. Yea right!
|
|
|
|
|
Is there any article on CodeProject about adding an icon in a statusbar?
I have searched but found nothing!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Do you mean system tray(the place where the clock is) then yes:
Adding Icons to the System Tray[^]
Le Ridder Noir
Considderd to be the worlds fastest knoppenbonker.
one year of working experience with the worlds fastest copie paster(about 2000 lines a minute).
And experience with the one and only NewEra Guru and Crystal Ace.
|
|
|
|
|
No, I mean the statusbar (CStatusBasr ) of a windows form or dialog on the bottom edge of the form.
|
|
|
|
|
|
I am trying to use CAsyncSocket to connect to the server
and wrote the code below:
...
CAsyncSocket asocket;
asocket.Create();//ok
asocket.Connect("server",999);//always failed
...
can anyone tell me what's the reason and how to resolve this problem.
thanks a lot.
|
|
|
|
|
did u call AfxSocketInit?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
yes, I called AfxSocketInit()
the problem is why CSocket works ok,but CAsyncSocket not?
thanks
|
|
|
|