illegal call of non-static ... 
Author Message
 illegal call of non-static ...

Did you leave something out? Neither of your function calls should work
since for funct1() you don't call it via an object and for funct2() you
don't use the class qualifier (i.e., anyone::funct2(20)).

If the above comments don't help, please post the *exact* code that causes
the problem.

--
_______________________________________________________

Barry L. Wallis, Senior Systems Engineer
Science Applications International Corporation
4161 Campus Point Court
San Diego, CA 92121
______________________________________________________


Quote:
> Compiler Error C2352
> 'class::function' : illegal call of
> non-static member function

> I only have to put the reserved word   static   in front of the member
> function to eliminate this error. But, I get a *.lib that throw the same
> error. I just want to know how to legaly call a non-static function.

> class anyone
> {
> public:
> int funct1(int);
> static int funct2(int);
> }

> int main()
> {
> int x = funct1(10); //// error c2352 .....
> int y = funct2(10); //// no error at all
> return 0;
> }

> Is there's a way to don't write static before every function.
> P.S. I don't want to change the *.h file.

> Thanks.



Sat, 17 Nov 2001 03:00:00 GMT  
 illegal call of non-static ...
Compiler Error C2352
'class::function' : illegal call of
non-static member function

I only have to put the reserved word   static   in front of the member
function to eliminate this error. But, I get a *.lib that throw the same
error. I just want to know how to legaly call a non-static function.

class anyone
{
public:
int funct1(int);
static int funct2(int);

Quote:
}

int main()
{
int x = funct1(10); //// error c2352 .....
int y = funct2(10); //// no error at all
return 0;

Quote:
}

Is there's a way to don't write static before every function.
P.S. I don't want to change the *.h file.

Thanks.



Sun, 18 Nov 2001 03:00:00 GMT  
 illegal call of non-static ...

Quote:
>I just want to know how to legaly call a non-static function.

Create the object first.

ex
class anyone
{
public:
int funct1(int);
static int funct2(int);

Quote:
}

int main()
{
anyone myanyone;
int x = myanyone.funct1(10);

// Static functions should be called like this.
int y = anyone::funct2(10);
return 0;

Quote:
}

Hope this helps

Vincent Minden

Quote:
> Compiler Error C2352
> 'class::function' : illegal call of
> non-static member function

> I only have to put the reserved word   static   in front of the member
> function to eliminate this error. But, I get a *.lib that throw the same
> error. I just want to know how to legaly call a non-static function.

> class anyone
> {
> public:
> int funct1(int);
> static int funct2(int);
> }

> int main()
> {
> int x = funct1(10); //// error c2352 .....
> int y = funct2(10); //// no error at all
> return 0;
> }

> Is there's a way to don't write static before every function.
> P.S. I don't want to change the *.h file.

> Thanks.



Sun, 18 Nov 2001 03:00:00 GMT  
 illegal call of non-static ...

Quote:

>Compiler Error C2352>'class::function' : illegal call of
>non-static member function

>I only have to put the reserved word   static   in front of the member
>function to eliminate this error. But, I get a *.lib that throw the same
>error. I just want to know how to legaly call a non-static function.

>class anyone
>{
>public:
>int funct1(int);
>static int funct2(int);
>}

>int main()
>{
>int x = funct1(10); //// error c2352 .....
>int y = funct2(10); //// no error at all
>return 0;
>}

>Is there's a way to don't write static before every function.
>P.S. I don't want to change the *.h file.

>Thanks.

int main()
{
anyone a;
int x = a.funct1(10); //// error c2352 .....
int y = a.funct2(10); //// no error at all
return 0;

Quote:
}

you need to have an instance of the class to call the member
function.

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/    The website for Visual C++ programmers.



Sun, 18 Nov 2001 03:00:00 GMT  
 illegal call of non-static ...
Thanks a lot.

Vincent Minden a crit dans le message ...

Quote:
>>I just want to know how to legaly call a non-static function.

>Create the object first.

>ex
>class anyone
>{
>public:
>int funct1(int);
>static int funct2(int);
>}

>int main()
>{
>anyone myanyone;
>int x = myanyone.funct1(10);



Mon, 19 Nov 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. illegal call of non-static member function

2. illegal call of non-static member function

3. illegal call of non-static member function *HELP*

4. illegal call of non-static member function

5. Illegal call of non-static member function (error)?

6. illegal call of non-static member function

7. Error C2352 - illegal call of non-static member function

8. Compiler Error C2352: illegal call of non-static member function

9. illegal call of non-static member function

10. One Problem in Calling Static function from Non static function

11. Nothing declared as static but: illegal call of non-static member function...

12. Calling non-static function...

 

 
Powered by phpBB® Forum Software