Solved

Compile error C2352?

Posted on 1997-11-05
1
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

738 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