Solved

Trying to use simple function in Windows Form application

Posted on 2010-11-11
7
724 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 and use structures in the C programming language.
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.

760 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

21 Experts available now in Live!

Get 1:1 Help Now