Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #6254 > unrolled thread
| Started by | Ruben Safir <ruben@mrbrklyn.com> |
|---|---|
| First post | 2011-06-06 01:19 +0000 |
| Last post | 2011-06-06 16:21 -0500 |
| Articles | 12 — 6 participants |
Back to article view | Back to comp.lang.c++
Linking Issue Ruben Safir <ruben@mrbrklyn.com> - 2011-06-06 01:19 +0000
Re: Linking Issue "Paul" <pchristor@yahoo.co.uk> - 2011-06-06 02:51 +0100
Re: Linking Issue red floyd <redfloyd@gmail.com> - 2011-06-06 10:16 -0700
Re: Linking Issue "Paul" <pchristor@yahoo.co.uk> - 2011-06-06 20:22 +0100
Re: Linking Issue Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-06 14:06 -0700
Re: Linking Issue Ruben Safir <ruben@mrbrklyn.com> - 2011-06-06 01:52 +0000
Re: Linking Issue Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-05 19:01 -0700
Re: Linking Issue Ruben Safir <ruben@mrbrklyn.com> - 2011-06-06 02:18 +0000
Re: Linking Issue "Paul" <pchristor@yahoo.co.uk> - 2011-06-06 03:24 +0100
Re: Linking Issue red floyd <redfloyd@gmail.com> - 2011-06-06 10:18 -0700
Re: Linking Issue ruben safir <ruben@mrbrklyn.com> - 2011-06-06 14:41 -0400
Re: Linking Issue Paavo Helde <myfirstname@osa.pri.ee> - 2011-06-06 16:21 -0500
| From | Ruben Safir <ruben@mrbrklyn.com> |
|---|---|
| Date | 2011-06-06 01:19 +0000 |
| Subject | Linking Issue |
| Message-ID | <ish9ur$c1k$1@reader1.panix.com> |
I'm just not undertstanding what I'm doing wrong that the linker can't
find my method function
I have this header file
questionss.h
#ifndef QUESTION
#define QUESTION
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <termios.h>
namespace Questions{
class Question{
public:
Question(std::string q, std::string a): quest(q), answer(a){ }
Question(){ }
Question(Question const ©){
this->quest = copy.quest;
this->response = copy.response;
this->answer = copy.answer;
}
std::string quest;
std::string response;
std::string answer;
private:
};
class Deck{
public:
std::vector<Question> deck;
Deck(){
std::string home = std::getenv("HOME");
database = home + "/quiz.db";
size = 0;
}
void get_stack();
Question get_question();
void give_quiz();
void add_questions(Question &enter);
void add_database();
Question create_question(std::ostream &os = std::cout, std::istream &in = std::cin );
private:
int size;
std::string database;
};
void menu(std::ostream &os = std::cout);
void selection(Deck, std::istream &in = std::cin);
} //end of namespace Question
#endif
this is a library file for questions ==> questions.cpp
/*
* =====================================================================================
*
* Filename: questions.cpp
*
* Description: Questions Class
*
* Version: 1.0
* Created: 06/05/2011 07:08:05 PM
* Revision: none
* Compiler: gcc
*
* Author: Ruben Safir (), ruben@mrbrklyn.com
* Company: NYLXS
*
* =====================================================================================
*/
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <termios.h>
#include "questions.h"
namespace Questions{
Question Deck::create_question(std::ostream &os , std::istream &in ){
struct termios stored_settings;
struct termios new_settings;
std::string input_q, input_a;
char keystroke;
os << "Please Enter your question below \n Enter <esc> when finished" << std::endl;
os << "==================================================================" << std::endl;
tcgetattr(0,&stored_settings);
new_settings = stored_settings;
/* Disable canonical mode, and set buffer size to 1 byte */
new_settings.c_lflag &= (~ICANON);
new_settings.c_cc[VTIME] = 0;
new_settings.c_cc[VMIN] = 1;
tcsetattr(0,TCSANOW,&new_settings);
while( (keystroke = getchar()) ){
if (keystroke == 27)
break;
input_q += keystroke;
}
os << "Please Enter your answer below \n Enter <esc> when finished" << std::endl;
os << "==================================================================" << std::endl;
while( (keystroke = getchar()) ){
if (keystroke == 27)
break;
input_a += keystroke;
}
Question quest(input_q, input_a);
tcsetattr(0,TCSANOW,&stored_settings);
return quest;
}
void menu(std::ostream &os){
os << "Welcome the the C++ Quiz" << "\n\n\n\n" << std::endl;
std::string tmp = " \n "
"Select from one of the following: \n\n"
"a) Insert Question and Answer into the database\n"
"b) Read 25 Questions and run Quiz\n\n\nResponse==> ";
os << tmp << std::endl;
}
void selection(Deck &stack, std::istream &is = std::cin) {
char choice;
Question tmp;
if(is >> choice){
switch ( choice ) {
case 'a':
tmp = stack.create_question();
stack.add_questions(tmp);
break;
case 'b':
break;
default:
break;
} /* ----- end switch ----- */
}
}
} /* End of Namespace Questions */
And this is the main program
#include <iostream>
#include "questions.h"
#include <string>
#include <vector>
int main(int argv, char *argc[]){
Questions::Deck stack;
Questions::menu();
Questions::selection(stack);
return 0;
}
and this is the makefile
CXX:=g++
CXXFLAGS:=-Wall -ggdb -pg
LDFLAGS:= -pg
quiz : quiz.o questions.o
$(CXX) $(LDFLAGS) -o quiz quiz.o questions.o
quiz.o : quiz.cpp questions.h
$(CXX) $(LDFLAGS) -c quiz.cpp
questions.o : questions.cpp questions.h
$(CXX) $(LDFLAGS) -c questions.cpp
include make.deps
make.deps: *.cpp; ${CXX} ${CXXFLAGS} -M *.cpp >$@
when I compile it I'm getting a linker error
:!make 2>&1| tee /tmp/vo1mDhy/8
g++ -pg -o quiz quiz.o questions.o
quiz.o: In function `main':
quiz.cpp:(.text+0x4b): undefined reference to `Questions::selection(Questions::Deck, std::basic_istream<char, std::char_traits<char> >&)'
questions.o: In function `Questions::selection(Questions::Deck&, std::basic_istream<char, std::char_traits<char> >&)':
questions.cpp:(.text+0x468): undefined reference to `Questions::Deck::add_questions(Questions::Question&)'
collect2: ld returned 1 exit status
make: *** [quiz] Error 1
(1 of 7): g++ -pg -o quiz quiz.o questions.o
The function is sitting there as plain as daylight
class Deck{
public:
std::vector<Question> deck;
Deck(){
std::string home = std::getenv("HOME");
database = home + "/quiz.db";
size = 0;
}
void get_stack();
Question get_question();
void give_quiz();
void add_questions(Question &enter); <<==========
[toc] | [next] | [standalone]
| From | "Paul" <pchristor@yahoo.co.uk> |
|---|---|
| Date | 2011-06-06 02:51 +0100 |
| Message-ID | <BoWGp.913$fQ4.808@newsfe16.ams2> |
| In reply to | #6254 |
"Ruben Safir" <ruben@mrbrklyn.com> wrote in message news:ish9ur$c1k$1@reader1.panix.com... > I'm just not undertstanding what I'm doing wrong that the linker can't > find my method function > > I have this header file > questionss.h > You need to link it in unison, try the options menu. Perhaps someone else can give you more specific information but I'm sorry this is the best I can do at this present moment in time as I am engulfed in a plethoria of pink floyd and hashish. Have you ever really listened to the dark side of the moon? Its really something else man.
[toc] | [prev] | [next] | [standalone]
| From | red floyd <redfloyd@gmail.com> |
|---|---|
| Date | 2011-06-06 10:16 -0700 |
| Message-ID | <1c5ed8ae-a55d-4733-a3d8-ca9acfc25846@m4g2000yqk.googlegroups.com> |
| In reply to | #6255 |
On Jun 5, 6:51 pm, "Paul" <pchris...@yahoo.co.uk> wrote: > "Ruben Safir" <ru...@mrbrklyn.com> wrote in message > > news:ish9ur$c1k$1@reader1.panix.com...> I'm just not undertstanding what I'm doing wrong that the linker can't > > find my method function > > > I have this header file > > questionss.h > > You need to link it in unison, try the options menu. Paul, you are a total idiot. He's using a makefile from the command line. There is no [censored] options menu.
[toc] | [prev] | [next] | [standalone]
| From | "Paul" <pchristor@yahoo.co.uk> |
|---|---|
| Date | 2011-06-06 20:22 +0100 |
| Message-ID | <gO9Hp.711$OC5.163@newsfe21.ams2> |
| In reply to | #6301 |
"red floyd" <redfloyd@gmail.com> wrote in message news:1c5ed8ae-a55d-4733-a3d8-ca9acfc25846@m4g2000yqk.googlegroups.com... On Jun 5, 6:51 pm, "Paul" <pchris...@yahoo.co.uk> wrote: > "Ruben Safir" <ru...@mrbrklyn.com> wrote in message > > news:ish9ur$c1k$1@reader1.panix.com...> I'm just not undertstanding what > I'm doing wrong that the linker can't > > find my method function > > > I have this header file > > questionss.h > > You need to link it in unison, try the options menu. --Paul, you are a total idiot. He's using a makefile from the command --line. --There is no [censored] options menu. My command line linker has an options menu. I type link /?
[toc] | [prev] | [next] | [standalone]
| From | Joshua Maurice <joshuamaurice@gmail.com> |
|---|---|
| Date | 2011-06-06 14:06 -0700 |
| Message-ID | <84989176-85e1-47a6-80b1-f0ece4d7e123@r35g2000prj.googlegroups.com> |
| In reply to | #6301 |
On Jun 6, 10:16 am, red floyd <redfl...@gmail.com> wrote: > On Jun 5, 6:51 pm, "Paul" <pchris...@yahoo.co.uk> wrote: > > > "Ruben Safir" <ru...@mrbrklyn.com> wrote in message > > >news:ish9ur$c1k$1@reader1.panix.com...> I'm just not undertstanding what I'm doing wrong that the linker can't > > > find my method function > > > > I have this header file > > > questionss.h > > > You need to link it in unison, try the options menu. > > Paul, you are a total idiot. He's using a makefile from the command > line. > There is no [censored] options menu. He is a troll. Do not feed the troll.
[toc] | [prev] | [next] | [standalone]
| From | Ruben Safir <ruben@mrbrklyn.com> |
|---|---|
| Date | 2011-06-06 01:52 +0000 |
| Message-ID | <ishbst$c1k$2@reader1.panix.com> |
| In reply to | #6254 |
http://www.nylxs.com/docs/quiz.tgz
On Mon, 06 Jun 2011 01:19:23 +0000, Ruben Safir wrote:
> I'm just not undertstanding what I'm doing wrong that the linker can't
> find my method function
>
> I have this header file
> questionss.h
>
>
> #ifndef QUESTION
> #define QUESTION
> #include <cstdlib>
> #include <cstdio>
> #include <string>
> #include <vector>
> #include <iostream>
> #include <iomanip>
> #include <termios.h>
>
> namespace Questions{
>
> class Question{
>
> public:
> Question(std::string q, std::string a): quest(q), answer(a){ }
> Question(){ }
> Question(Question const ©){
> this->quest = copy.quest;
> this->response = copy.response;
> this->answer = copy.answer;
> }
> std::string quest;
> std::string response;
> std::string answer;
>
>
>
>
>
>
>
> private:
>
>
>
> };
>
> class Deck{
>
> public:
> std::vector<Question> deck;
> Deck(){
> std::string home = std::getenv("HOME"); database = home +
> "/quiz.db";
> size = 0;
> }
>
>
>
> void get_stack();
> Question get_question();
> void give_quiz();
> void add_questions(Question &enter);
> void add_database();
> Question create_question(std::ostream &os = std::cout,
> std::istream &in = std::cin );
>
> private:
> int size;
> std::string database;
>
> };
>
>
> void menu(std::ostream &os = std::cout); void selection(Deck,
> std::istream &in = std::cin);
>
>
> } //end of namespace Question
>
>
> #endif
>
>
>
> this is a library file for questions ==> questions.cpp /*
> *
> =====================================================================================
> *
> * Filename: questions.cpp
> *
> * Description: Questions Class
> *
> * Version: 1.0
> * Created: 06/05/2011 07:08:05 PM * Revision: none
> * Compiler: gcc
> *
> * Author: Ruben Safir (), ruben@mrbrklyn.com * Company:
> NYLXS
> *
> *
> =====================================================================================
> */
>
> #include <cstdlib>
> #include <cstdio>
> #include <string>
> #include <vector>
> #include <iostream>
> #include <iomanip>
> #include <termios.h>
> #include "questions.h"
>
> namespace Questions{
>
> Question Deck::create_question(std::ostream &os , std::istream &in ){
> struct termios stored_settings;
> struct termios new_settings;
> std::string input_q, input_a;
> char keystroke;
>
>
> os << "Please Enter your question below \n Enter <esc> when
> finished" << std::endl; os <<
> "=================================================================="
> << std::endl;
>
> tcgetattr(0,&stored_settings);
>
> new_settings = stored_settings;
>
> /* Disable canonical mode, and set buffer size to 1 byte */
> new_settings.c_lflag &= (~ICANON);
> new_settings.c_cc[VTIME] = 0;
> new_settings.c_cc[VMIN] = 1;
>
> tcsetattr(0,TCSANOW,&new_settings);
>
> while( (keystroke = getchar()) ){
> if (keystroke == 27)
> break;
> input_q += keystroke;
> }
> os << "Please Enter your answer below \n Enter <esc> when
> finished" << std::endl; os <<
> "=================================================================="
> << std::endl;
>
> while( (keystroke = getchar()) ){
> if (keystroke == 27)
> break;
> input_a += keystroke;
> }
>
> Question quest(input_q, input_a);
>
>
>
>
> tcsetattr(0,TCSANOW,&stored_settings); return quest;
> }
>
> void menu(std::ostream &os){
> os << "Welcome the the C++ Quiz" << "\n\n\n\n" << std::endl;
> std::string tmp = " \n "
> "Select from one of the following: \n\n" "a) Insert Question and
> Answer into the database\n" "b) Read 25 Questions and run
> Quiz\n\n\nResponse==> ";
>
> os << tmp << std::endl;
>
> }
>
>
> void selection(Deck &stack, std::istream &is = std::cin) {
> char choice;
> Question tmp;
> if(is >> choice){
>
> switch ( choice ) {
> case 'a':
> tmp = stack.create_question();
> stack.add_questions(tmp);
> break;
>
> case 'b':
> break;
>
> default:
> break;
> } /* ----- end switch ----- */
> }
> }
>
> } /* End of Namespace Questions */
>
>
> And this is the main program
>
> #include <iostream>
> #include "questions.h"
> #include <string>
> #include <vector>
>
> int main(int argv, char *argc[]){
>
> Questions::Deck stack;
>
> Questions::menu();
> Questions::selection(stack);
>
> return 0;
> }
>
> and this is the makefile
> CXX:=g++
> CXXFLAGS:=-Wall -ggdb -pg
> LDFLAGS:= -pg
>
> quiz : quiz.o questions.o
> $(CXX) $(LDFLAGS) -o quiz quiz.o questions.o
>
> quiz.o : quiz.cpp questions.h
> $(CXX) $(LDFLAGS) -c quiz.cpp
>
> questions.o : questions.cpp questions.h
> $(CXX) $(LDFLAGS) -c questions.cpp
>
>
>
> include make.deps
> make.deps: *.cpp; ${CXX} ${CXXFLAGS} -M *.cpp >$@
>
>
>
>
> when I compile it I'm getting a linker error
>
>
> :!make 2>&1| tee /tmp/vo1mDhy/8
> g++ -pg -o quiz quiz.o questions.o
> quiz.o: In function `main':
> quiz.cpp:(.text+0x4b): undefined reference to
> `Questions::selection(Questions::Deck, std::basic_istream<char,
> std::char_traits<char> >&)' questions.o: In function
> `Questions::selection(Questions::Deck&, std::basic_istream<char,
> std::char_traits<char> >&)': questions.cpp:(.text+0x468): undefined
> reference to `Questions::Deck::add_questions(Questions::Question&)'
> collect2: ld returned 1 exit status
> make: *** [quiz] Error 1
> (1 of 7): g++ -pg -o quiz quiz.o questions.o
>
>
>
> The function is sitting there as plain as daylight
> class Deck{
>
> public:
> std::vector<Question> deck;
> Deck(){
> std::string home = std::getenv("HOME"); database = home +
> "/quiz.db";
> size = 0;
> }
>
>
>
> void get_stack();
> Question get_question();
> void give_quiz();
> void add_questions(Question &enter); <<==========
[toc] | [prev] | [next] | [standalone]
| From | Joshua Maurice <joshuamaurice@gmail.com> |
|---|---|
| Date | 2011-06-05 19:01 -0700 |
| Message-ID | <aea78216-7dd3-4778-84fc-d1e13d777259@34g2000pru.googlegroups.com> |
| In reply to | #6254 |
On Jun 5, 6:19 pm, Ruben Safir <ru...@mrbrklyn.com> wrote:
> I'm just not undertstanding what I'm doing wrong that the linker can't
> find my method function
>
> I have this header file
> questionss.h
>
> #ifndef QUESTION
> #define QUESTION
> #include <cstdlib>
> #include <cstdio>
> #include <string>
> #include <vector>
> #include <iostream>
> #include <iomanip>
> #include <termios.h>
>
> namespace Questions{
>
> class Question{
>
> public:
> Question(std::string q, std::string a): quest(q), answer(a){ }
> Question(){ }
> Question(Question const ©){
> this->quest = copy.quest;
> this->response = copy.response;
> this->answer = copy.answer;
> }
> std::string quest;
> std::string response;
> std::string answer;
>
> private:
>
> };
>
> class Deck{
>
> public:
> std::vector<Question> deck;
> Deck(){
> std::string home = std::getenv("HOME");
> database = home + "/quiz.db";
> size = 0;
> }
>
> void get_stack();
> Question get_question();
> void give_quiz();
> void add_questions(Question &enter);
> void add_database();
> Question create_question(std::ostream &os = std::cout, std::istream &in = std::cin );
>
> private:
> int size;
> std::string database;
>
> };
>
> void menu(std::ostream &os = std::cout);
> void selection(Deck, std::istream &in = std::cin);
>
> } //end of namespace Question
>
> #endif
>
> this is a library file for questions ==> questions.cpp
> /*
> * =====================================================================================
> *
> * Filename: questions.cpp
> *
> * Description: Questions Class
> *
> * Version: 1.0
> * Created: 06/05/2011 07:08:05 PM
> * Revision: none
> * Compiler: gcc
> *
> * Author: Ruben Safir (), ru...@mrbrklyn.com
> * Company: NYLXS
> *
> * =====================================================================================
> */
>
> #include <cstdlib>
> #include <cstdio>
> #include <string>
> #include <vector>
> #include <iostream>
> #include <iomanip>
> #include <termios.h>
> #include "questions.h"
>
> namespace Questions{
>
> Question Deck::create_question(std::ostream &os , std::istream &in ){
> struct termios stored_settings;
> struct termios new_settings;
> std::string input_q, input_a;
> char keystroke;
>
> os << "Please Enter your question below \n Enter <esc> when finished" << std::endl;
> os << "==================================================================" << std::endl;
>
> tcgetattr(0,&stored_settings);
>
> new_settings = stored_settings;
>
> /* Disable canonical mode, and set buffer size to 1 byte */
> new_settings.c_lflag &= (~ICANON);
> new_settings.c_cc[VTIME] = 0;
> new_settings.c_cc[VMIN] = 1;
>
> tcsetattr(0,TCSANOW,&new_settings);
>
> while( (keystroke = getchar()) ){
> if (keystroke == 27)
> break;
> input_q += keystroke;
> }
> os << "Please Enter your answer below \n Enter <esc> when finished" << std::endl;
> os << "==================================================================" << std::endl;
>
> while( (keystroke = getchar()) ){
> if (keystroke == 27)
> break;
> input_a += keystroke;
> }
>
> Question quest(input_q, input_a);
>
> tcsetattr(0,TCSANOW,&stored_settings);
> return quest;
> }
>
> void menu(std::ostream &os){
> os << "Welcome the the C++ Quiz" << "\n\n\n\n" << std::endl;
> std::string tmp = " \n "
> "Select from one of the following: \n\n"
> "a) Insert Question and Answer into the database\n"
> "b) Read 25 Questions and run Quiz\n\n\nResponse==> ";
>
> os << tmp << std::endl;
>
> }
>
> void selection(Deck &stack, std::istream &is = std::cin) {
> char choice;
> Question tmp;
> if(is >> choice){
>
> switch ( choice ) {
> case 'a':
> tmp = stack.create_question();
> stack.add_questions(tmp);
> break;
>
> case 'b':
> break;
>
> default:
> break;
> } /* ----- end switch ----- */
> }
> }
>
> } /* End of Namespace Questions */
>
> And this is the main program
>
> #include <iostream>
> #include "questions.h"
> #include <string>
> #include <vector>
>
> int main(int argv, char *argc[]){
>
> Questions::Deck stack;
>
> Questions::menu();
> Questions::selection(stack);
>
> return 0;
>
> }
>
> and this is the makefile
> CXX:=g++
> CXXFLAGS:=-Wall -ggdb -pg
> LDFLAGS:= -pg
>
> quiz : quiz.o questions.o
> $(CXX) $(LDFLAGS) -o quiz quiz.o questions.o
>
> quiz.o : quiz.cpp questions.h
> $(CXX) $(LDFLAGS) -c quiz.cpp
>
> questions.o : questions.cpp questions.h
> $(CXX) $(LDFLAGS) -c questions.cpp
>
> include make.deps
> make.deps: *.cpp; ${CXX} ${CXXFLAGS} -M *.cpp >$@
>
> when I compile it I'm getting a linker error
>
> :!make 2>&1| tee /tmp/vo1mDhy/8
> g++ -pg -o quiz quiz.o questions.o
> quiz.o: In function `main':
> quiz.cpp:(.text+0x4b): undefined reference to `Questions::selection(Questions::Deck, std::basic_istream<char, std::char_traits<char> >&)'
> questions.o: In function `Questions::selection(Questions::Deck&, std::basic_istream<char, std::char_traits<char> >&)':
> questions.cpp:(.text+0x468): undefined reference to `Questions::Deck::add_questions(Questions::Question&)'
> collect2: ld returned 1 exit status
> make: *** [quiz] Error 1
> (1 of 7): g++ -pg -o quiz quiz.o questions.o
>
> The function is sitting there as plain as daylight
[...]
> void add_questions(Question &enter); <<==========
Did you actually give the function a body? Did you compile that object
file, and give that object file in addition to the linker when
linking?
[toc] | [prev] | [next] | [standalone]
| From | Ruben Safir <ruben@mrbrklyn.com> |
|---|---|
| Date | 2011-06-06 02:18 +0000 |
| Message-ID | <ishdcs$c1k$3@reader1.panix.com> |
| In reply to | #6257 |
On Sun, 05 Jun 2011 19:01:52 -0700, Joshua Maurice wrote: > Did you actually give the function a body? Did you compile that object > file, and give that object file in addition to the linker when linking? I finally got it. I didn't give the function a definition and i also altered the makefile to make the error it clearer. It wasn't giving me -ggdb
[toc] | [prev] | [next] | [standalone]
| From | "Paul" <pchristor@yahoo.co.uk> |
|---|---|
| Date | 2011-06-06 03:24 +0100 |
| Message-ID | <NTWGp.15361$Dk2.4414@newsfe04.ams2> |
| In reply to | #6258 |
"Ruben Safir" <ruben@mrbrklyn.com> wrote in message news:ishdcs$c1k$3@reader1.panix.com... > On Sun, 05 Jun 2011 19:01:52 -0700, Joshua Maurice wrote: > > >> Did you actually give the function a body? Did you compile that object >> file, and give that object file in addition to the linker when linking? > > > > I finally got it. I didn't give the function a definition and i also > altered the > makefile to make the error it clearer. It wasn't giving me -ggdb > No Problem I'm glad I managed to solve this problem for you , just by being stoned ;-)
[toc] | [prev] | [next] | [standalone]
| From | red floyd <redfloyd@gmail.com> |
|---|---|
| Date | 2011-06-06 10:18 -0700 |
| Message-ID | <e4f6dfea-4940-46ac-9c65-8b6eb5823e1f@w4g2000yqm.googlegroups.com> |
| In reply to | #6254 |
On Jun 5, 6:19 pm, Ruben Safir <ru...@mrbrklyn.com> wrote:
> I'm just not undertstanding what I'm doing wrong that the linker can't
> find my method function
>
> I have this header file
> questionss.h
[redacted]
> void selection(Deck, std::istream &in = std::cin);
> [redacted]
> questions.cpp
> void selection(Deck &stack, std::istream &is = std::cin) {
And the problem becomes clear. The prototype passes the deck
by value, the actual function passes by reference.
[toc] | [prev] | [next] | [standalone]
| From | ruben safir <ruben@mrbrklyn.com> |
|---|---|
| Date | 2011-06-06 14:41 -0400 |
| Message-ID | <isj715$i9v$1@reader1.panix.com> |
| In reply to | #6302 |
On 06/06/2011 01:18 PM, red floyd wrote:
> On Jun 5, 6:19 pm, Ruben Safir<ru...@mrbrklyn.com> wrote:
>> I'm just not undertstanding what I'm doing wrong that the linker can't
>> find my method function
>>
>> I have this header file
>> questionss.h
> [redacted]
>> void selection(Deck, std::istream&in = std::cin);
>> [redacted]
>> questions.cpp
>> void selection(Deck&stack, std::istream&is = std::cin) {
>
>
> And the problem becomes clear. The prototype passes the deck
> by value, the actual function passes by reference.
huh
why is it compiling now then :) Another mystery.
good catch.
Ruben
[toc] | [prev] | [next] | [standalone]
| From | Paavo Helde <myfirstname@osa.pri.ee> |
|---|---|
| Date | 2011-06-06 16:21 -0500 |
| Message-ID | <Xns9EFD39A89746myfirstnameosapriee@216.196.109.131> |
| In reply to | #6308 |
ruben safir <ruben@mrbrklyn.com> wrote in news:isj715$i9v$1 @reader1.panix.com: > why is it compiling now then :) Another mystery. > No mystery. For compiling you need only function declarations (prototypes). For linking or running you need the corresponding definitions as well. And providing an unrelated unused function definition is not an error, it just gets ignored. This is mostly a problem with free functions. If you want to get a compile- time error for such things, you can always put all functions inside some class as (maybe static) member functions. hth Paavo
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++
csiph-web