[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

cannot call member function 'void CReg::GetStrValue(const char*, std::string&)' without object

neilsolent

11/26/2008 9:09:00 PM

Hi

I get the error in the subject line when I try to call a static member
of my class CReg like this:

CReg::GetStrValue("test", mystring);

This is with g++ (on Solaris as it happens). This is perfectly
allowable in Visual C++ on Windows.

What do I need to do? I don't intend to instantiate the CReg class at
any point in the program

thanks!
5 Answers

Jeff Schwab

11/26/2008 9:12:00 PM

0

neilsolent wrote:

> I get the error in the subject line when I try to call a static member
> of my class CReg like this:
>
> CReg::GetStrValue("test", mystring);
>
> This is with g++ (on Solaris as it happens). This is perfectly
> allowable in Visual C++ on Windows.
>
> What do I need to do? I don't intend to instantiate the CReg class at
> any point in the program

Can you post a complete program? The problem isn't with what you've
shown, although its sounds like g++ doesn't think the member is static.

Ian Collins

11/26/2008 9:13:00 PM

0

neilsolent wrote:
> Hi
>
> I get the error in the subject line when I try to call a static member
> of my class CReg like this:
>
Put the error in the body of your post, it's easier to read that way.

> CReg::GetStrValue("test", mystring);
>
> This is with g++ (on Solaris as it happens). This is perfectly
> allowable in Visual C++ on Windows.
>
> What do I need to do? I don't intend to instantiate the CReg class at
> any point in the program
>
The error implies the member isn't static. Post the declaration.

--
Ian Collins

neilsolent

11/26/2008 9:17:00 PM

0


> Can you post a complete program?  The problem isn't with what you've
> shown, although its sounds like g++ doesn't think the member is static.

Jeff - thanks, that did it! I'd just missed off the static keywords in
the header file :-(
Sorry - just porting a program from Windows to UNIX and lacking a bit
of experience

Andrey Tarasevich

11/26/2008 9:28:00 PM

0

neilsolent wrote:
> Sorry - just porting a program from Windows to UNIX and lacking a bit
> of experience

Does this mean that you could call a non-static member function without
an object under Windows?

--
Best regards,
Andrey Tarasevich

neilsolent

11/26/2008 9:36:00 PM

0

> Does this mean that you could call a non-static member function without
> an object under Windows?
>

No - only a static one. All's well with the world - just a typo