Solved

Trying to use simple function in Windows Form application

Posted on 2010-11-11
7
727 Views
Last Modified: 2012-05-10
Hello experts.

Created simple windows form application in VC++ 2008.

Please have a look at the code below:

private: System::Void listBox1_Click(System::Object^  sender, System::EventArgs^  e)
                   {
                         String^ s;

                         if ( listBox1->SelectedIndex != -1 )
                              s = listBox1->SelectedItems[0]->ToString();

                         aaa(1);
   
                         
                         

                   }
      };


As you can see, I try to call "aaa(1)".


My "Headers.h":

#include "stdafx.h"

int aaa(int a);



My "Functions.cpp":

#include "stdafx.h"

int aaa(int a)
{
      return -1;
      
}




But get two errors:

OpenCV tester.obj : error LNK2028: unresolved token (0A00000A) "int __clrcall OpenCVtester::aaa(int)" (?aaa@OpenCVtester@@$$FYMHH@Z) referenced in function "private: void __clrcall OpenCVtester::Form1::listBox1_Click(class System::Object ^,class System::EventArgs ^)" (?listBox1_Click@Form1@OpenCVtester@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
OpenCV tester.obj : error LNK2019: unresolved external symbol "int __clrcall OpenCVtester::aaa(int)" (?aaa@OpenCVtester@@$$FYMHH@Z) referenced in function "private: void __clrcall OpenCVtester::Form1::listBox1_Click(class System::Object ^,class System::EventArgs ^)" (?listBox1_Click@Form1@OpenCVtester@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)

Why is that?



Thank you

panJames
0
Comment
Question by:panJames
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:panJames
ID: 34112497
And of course I added:

#include "Headers.h"


panJames
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 34113654
Did you try:
::aaa(1);  // calling function with global scope
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 34113663
What are you trying to do?
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:panJames
ID: 34119257
I am just learning/ experimenting.

Did what u suggested. Got an error:

error C2039: 'aaa' : is not a member of '`global namespace''

panJames
0
 
LVL 8

Expert Comment

by:Subrat (C++ windows/Linux)
ID: 34119269
I think your aaa() is written inside a class???

If so, then Use
int ClassName::aaa(int a) {
  // Write your code ...
  return -1;
}
0
 

Author Comment

by:panJames
ID: 34119429
Subrat, as mentioned in my first post:

My "Functions.cpp":

#include "stdafx.h"

int aaa(int a)
{
      return -1;
     
}

panJames
0
 
LVL 8

Accepted Solution

by:
Subrat (C++ windows/Linux) earned 500 total points
ID: 34133362
Include headers.h in Functions.cpp and wherever you are using aaa() there, include "Headers.h"
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
My eclipse editor won't start ? 4 144
C++ check and remove last word from a string 5 145
SQL handling single and double quotes 3 94
How to install SVN Command Line Client? 5 43
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

867 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

20 Experts available now in Live!

Get 1:1 Help Now