Linking Error - Static vs. Non-Static 
Author Message
 Linking Error - Static vs. Non-Static

I'm a newbie to MFC.

I just used the app wizard to create an MFC shell.  I added 2 classes we'll
call CClass1, and CClass2.  I have functions in both classes.  I want to be
able to call functions in CClass1 from within CClass2.  When I do this, I get
an error indicating I am making an illegal call of a non static function,
referring to the one in CClass1.  If I make the CClass1 prototype Static, I
get errors for the calls to the function from within CClass1 saying it
shouldn't be static.

I am in a catch 22 here.  What is the solution?

Thanks for any help.

John



Tue, 28 Nov 2000 03:00:00 GMT  
 Linking Error - Static vs. Non-Static

    I'm going to guess here. It sounds like you are trying to call a function in
Class1 from Class2 as-is, without instantiating any Class1 object. If that is
correct, what you really want to do is make Class2 a 'friend' of Class1. See
Friend Classes in the documentation. If that isn't what you are attempting -
never mind!
- Doug S.


Quote:
> I'm a newbie to MFC.

> I just used the app wizard to create an MFC shell.  I added 2 classes we'll
> call CClass1, and CClass2.  I have functions in both classes.  I want to be
> able to call functions in CClass1 from within CClass2.  When I do this, I get
> an error indicating I am making an illegal call of a non static function,
> referring to the one in CClass1.  If I make the CClass1 prototype Static, I
> get errors for the calls to the function from within CClass1 saying it
> shouldn't be static.

> I am in a catch 22 here.  What is the solution?

> Thanks for any help.

> John



Tue, 28 Nov 2000 03:00:00 GMT  
 Linking Error - Static vs. Non-Static

If you supply a code snippet with the minimum code needed to reporduce the
error, a definite answer can and will be given.  You haven't given enough
data to be anything more than a random guess.  No need to give away any
proprietary secrets as to what exactly the code does, just raw syntax that
causes the problem will do!
--
Please remove the kitty litter eating from in front of the reply address.



Quote:
> I'm a newbie to MFC.

> I just used the app wizard to create an MFC shell.  I added 2 classes
we'll
> call CClass1, and CClass2.  I have functions in both classes.  I want to
be
> able to call functions in CClass1 from within CClass2.  When I do this, I
get
> an error indicating I am making an illegal call of a non static function,
> referring to the one in CClass1.  If I make the CClass1 prototype Static,
I
> get errors for the calls to the function from within CClass1 saying it
> shouldn't be static.

> I am in a catch 22 here.  What is the solution?

> Thanks for any help.

> John



Tue, 28 Nov 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Linking Static DLL vs Non Static DLL

2. Pointers to non-static vs static functions

3. Error linking static MFC and static C/C++ runtime

4. New vs.net static library project generates LINK errors

5. New vs.net static library project generates LINK errors

6. static vs. shared compile link errors

7. Static and non-Static member - Signature

8. Creating a static class from non static Framework classes

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

10. static versus non static returnvalues

11. Static array containing non static objects and functions

12. Accessing non-static functions from a static function

 

 
Powered by phpBB® Forum Software