Solved

Compile error C2352?

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 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

12 Experts available now in Live!

Get 1:1 Help Now