Solved

Compile error C2352?

Posted on 1997-11-05
1
294 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

839 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