User forums > Using Code::Blocks
Calling functions from other .cpp files
(1/1)
msinfo:
Hello Experts,
I am newbie in C++ (code blocks too).
I am calling one function (funSay) from input.cpp file to main.cpp file, but it won't run because of undefined reference error.
Kindly refer image for actual code and error message
main.cpp
--- Code: ---#include <iostream> // helps with input and out put related tasks
#include <limits> // helps to use max and min functions
#include <ctime> // helps to use time functions
#include <time.h> // help with time functions
#include "myhead.h"
using std::time_t;
using std::time;
using std::localtime;
using std::asctime;
using namespace std; // helps to use cout and cin
void funSay();
void funinput();
void funVariable();
void funTime();
int main()
{
cout << "Hello world!" << endl;
funSay(); // calls function named funVariable
return 0;
}
--- End code ---
input.cpp
--- Code: ---void funSay()
{
cout << "from another file" << endl;
}
--- End code ---
myhead.h
--- Code: ---#ifndef _MYHEAD_H
#define _MYHEAD_H
void funSay();
#endif
--- End code ---
Second, how do i upload image, code, quote in forum text.
Clicking on given options only seems to add [img] kind of text only.
Even when my post shows 0 count, I still get error message
"You already submitted this post! You might have accidently double clicked, or tried to refresh."
:'(
With regards : Msinfo
jarod42:
I suspect that you don't have project.
You should create a project with all needed files (main.cpp, input.cpp, myhead.h)
And for the posting Question:
After clicking on button (Insert Image), you have to write the url corresponding to your image.
MortenMacFly:
--- Quote from: msinfo on October 15, 2012, 05:00:39 pm ---I am newbie in C++ (code blocks too).
--- End quote ---
Sorry, but this is the wrong forum. There are plenty of C++ forums around that can help you with this type of questions. This forum is about Code::Blocks, an IDE - NOT about general programming issues.
If you have questions related to Code::Blocks (like how to configure a compiler, how to use the interface or alike) feel free to post here.
BTW: When registering with the forums you were notified about the forum rules which you just skipped probably. So please read here:
http://forums.codeblocks.org/index.php/topic,9996.0.html
Topic locked.
Navigation
[0] Message Index
Go to full version