Solved

Compile error C2352?

Posted on 1997-11-05
1
292 Views
Last Modified: 2006-11-17
What is the correct way to return a value from a function?  I have a dialog class and I want to actually get multiple values from a database table.  However, in testing I have tried to implement a return value of a CString object to a Textbox control on the dialog.  When using STATIC return values, no problem.  However with the following function call in my CFindWebDialog class:

m_pTestString = CWWatchView::Testing();

I get the following error:
Compiler Error C2352

'class::function' : illegal call of non-static member function

The specified nonstatic member function was called in a static member function.


The CWWatchView::Testing() function is defined:

CString CWWatchView::Testing()
{
    return "HELP!";
}

What is the correct construct?

Thanks

Brent
0
Comment
Question by:bknouse
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1172630
This error has nothing to do with the return value. If the Testing() function is a static member function of CWWatchView class, you can call the function by using CWWatchView::Testing(). But if it is not a static member function, you need to create an instance of the class (ie. an object) or get the pointer to the object in order to call the member function.

CWWatchView *pWWV;

// get the value of pWWV
...

m_pTestString = pWWV->Testing();

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now