Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Compile error C2352?

Posted on 1997-11-05
1
Medium Priority
?
307 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 200 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

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. …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

715 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