By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 888 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Undefined reference in G++.

P: n/a
Hi!

I'm writing a class that have a static function

class Servicios {
public:
static String * intToString(int value);
};

an another class String that I write to.

namespace DataTypes {
class String {
......
};

ostream& operator<< (ostream&, const String &);
istream& operator>>(istream&, String &)
}

the class String has two iostream functions implemented outside the
class.

I have to a main.cc that has something like this:

int main() {
String * str = Servicios::intToString(100);
cout << str;

}

but when I do a make from all this, I have the error

In main.cc: undefined reference to .............function
ostream....(....)
Questions:
what is undefined reference? when ocurr? how to solve this problem?

thanks a lot.

Andrix.

Jun 21 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
* Andrix:

I'm writing a class that have a static function

class Servicios {
public:
static String * intToString(int value);
};
Who is responsible for deallocating that String, and how?

Better use std::string.

an another class String that I write to.

namespace DataTypes {
class String {
......
};

ostream& operator<< (ostream&, const String &);
istream& operator>>(istream&, String &)
}

the class String has two iostream functions implemented outside the
class.

I have to a main.cc that has something like this:

int main() {
String * str = Servicios::intToString(100);
cout << str;
That will output a pointer value.

}

but when I do a make from all this, I have the error

In main.cc: undefined reference to .............function
ostream....(....)
Questions:
what is undefined reference?
That your program is using something that is not defined.

when ocurr?
You haven't shown the relevant code.

how to solve this problem?


Define whatever is missing.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jun 21 '06 #2

P: n/a
Andrix wrote:
Hi!

I'm writing a class that have a static function

class Servicios {
public:
static String * intToString(int value);
};

an another class String that I write to.

namespace DataTypes {
class String {
......
};

ostream& operator<< (ostream&, const String &);
istream& operator>>(istream&, String &)
}

the class String has two iostream functions implemented outside the
class.

I have to a main.cc that has something like this:

int main() {
String * str = Servicios::intToString(100);
cout << str;

}

but when I do a make from all this, I have the error

In main.cc: undefined reference to .............function
ostream....(....)
Questions:
what is undefined reference? when ocurr? how to solve this problem?


You're trying to invoke operator<<(ostream&, const String *). It's not
defined anywhere. Why are you returing a String* from intToString,
rather than a String?
Jun 21 '06 #3

P: n/a
* red floyd:
Andrix wrote:
Hi!

I'm writing a class that have a static function

class Servicios {
public:
static String * intToString(int value);
};

an another class String that I write to.

namespace DataTypes {
class String {
......
};

ostream& operator<< (ostream&, const String &);
istream& operator>>(istream&, String &)
}

the class String has two iostream functions implemented outside the
class.

I have to a main.cc that has something like this:

int main() {
String * str = Servicios::intToString(100);
cout << str;

}

but when I do a make from all this, I have the error

In main.cc: undefined reference to .............function
ostream....(....)
Questions:
what is undefined reference? when ocurr? how to solve this problem?


You're trying to invoke operator<<(ostream&, const String *).


Output of void* is defined. Nothing in the code shown indicates that
operator<<(ostream&, const String*) is invoked. We don't know what the
missing function is because the OP has replaced all info with periods.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jun 21 '06 #4

P: n/a
Alf P. Steinbach wrote:
* red floyd:


You're trying to invoke operator<<(ostream&, const String *).


Output of void* is defined. Nothing in the code shown indicates that
operator<<(ostream&, const String*) is invoked. We don't know what the
missing function is because the OP has replaced all info with periods.


Crud. Forgot about the automatic conversion to void*.
Jun 22 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.