-
October 3rd, 2012, 04:06 PM
#1
Pointer/Reference to Class within a Class within a Class
I have encountered a problem I can't see to solve. I want to access a function and can't seem to find the right combination to get me there. Here is what I am looking at:
CFoo1::CFoo2::GetStrDataC(int nRow) const
How do I call the GetStrDataC function from another class?
Thanks for the help!
John
-
October 3rd, 2012, 04:25 PM
#2
Re: Pointer/Reference to Class within a Class within a Class
Is it a static function?
Is it declared as public?
Victor Nijegorodov
-
October 3rd, 2012, 04:36 PM
#3
Re: Pointer/Reference to Class within a Class within a Class
It is a helper class in a Protected area. Not Static.
John
-
October 3rd, 2012, 04:42 PM
#4
Re: Pointer/Reference to Class within a Class within a Class
Could you show the declarations?
Victor Nijegorodov
-
October 3rd, 2012, 05:09 PM
#5
Re: Pointer/Reference to Class within a Class within a Class
//------------------------------------------------------------------------
// Summary:
// This is helper class designed to manage a set of strings
//------------------------------------------------------------------------
class _EXT_CLASS CFooStringsManager
{
//{{AFX_CFOO_PRIVATE
friend class CFooEditBufferManager;
//}}AFX_CFOO_PRIVATE
public:
//----------------------------------------------------------------------
// Summary:
// Default object constructor.
//----------------------------------------------------------------------
CFooEditStringsManager();
//----------------------------------------------------------------------
// Summary:
// Default object destructor. Handles cleanup and deallocation
//----------------------------------------------------------------------
virtual ~CFooEditStringsManager();
-
October 3rd, 2012, 08:51 PM
#6
Re: Pointer/Reference to Class within a Class within a Class
Originally Posted by JohnWHagen
//------------------------------------------------------------------------
// Summary:
// This is helper class designed to manage a set of strings
//------------------------------------------------------------------------
class _EXT_CLASS CFooStringsManager
{
//{{AFX_CFOO_PRIVATE
friend class CFooEditBufferManager;
//}}AFX_CFOO_PRIVATE
public:
//----------------------------------------------------------------------
// Summary:
// Default object constructor.
//----------------------------------------------------------------------
CFooEditStringsManager();
//----------------------------------------------------------------------
// Summary:
// Default object destructor. Handles cleanup and deallocation
//----------------------------------------------------------------------
virtual ~CFooEditStringsManager();
1) Please use code tags when posting code.
2) When you get a compiler error, it helps to post the complete code that doesn't compile, and not a description of what doesn't compile.
3) That function must be a static function, since you cannot just call a non-static member function without an instance of the object.
I can get your situation to compile very easily, but I bet it isn't what you actually are trying to compile:
Code:
class CFoo1
{
public:
class CFoo2
{
public:
void GetStrData() const;
};
CFoo2 foo2;
};
int main()
{
CFoo1 theFoo;
theFoo.foo2.GetStrData();
}
There is no need for the scope resolution operator, as you must have a CFoo2 object (the foo2 member) to use the inner class. So show how your code differs in form to the code above.
Regards,
Paul McKenzie
-
October 4th, 2012, 09:46 AM
#7
Re: Pointer/Reference to Class within a Class within a Class
Thanks for the sample code. It does explain some of what I did not know.
The code I am trying to understand is from a commercial vendor. I purchased it three years ago and they have since moved on to an updated version. After some digging I did find the problem I am having was not an error on my part but one they did not detect. An updated patch solved my problem.
This too is what I did not upload much of the code or the compiler error. I don't need issues with companies balking about exposing their source code (I paid for it) and don't need the legal eagles headed my way.
Thanks to you both for the assistance. It helps those of us who learn much of this on our own. Somedays we make great progress. Other days it may only be a line or two of code. I enjoy the challenges but really take pride in the successes!
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|