M
Markus Dehmann
I have started with C++ a few months ago. The language itself is nice,
but what I really don't like are the error messages that I get from
g++.
g++ error messages are often just not helpful.
Sometimes I just take the line number of the error and try to figure
out myself what might be wrong. Or I just remember this error message
and know already: if g++ says error X it really means error Y.
For example, take the following code:
#include <iostream>
class Interface{
public:
virtual std::string &getText() const = 0;
};
class Implementation : public Interface{
std::string text;
public:
Implementation::Implementation(std::string text):text(text){}
std::string &getText() const{
return text;
}
};
bash-2.05b$ g++ -c test.cpp
test.cpp: In member function `virtual std::string&
Implementation::getText()
const':
test.cpp:13: could not convert `this->Implementation::text' to
`std::string&'
The return type of getText() must not be std::string, but const
std::string. But why doesn't g++ just say that? It could say: "Could
not return reference to this->... from a const method"...
For beginners, it's also intimidating to get an error message that
fills several screens from the STL usage
std::vector<std::string> test;
std::cout << test;
The whole "candidates are..." list with 26 entries is anyway
unreadable... There should be a better, more readable way to indicate
an error.
Markus
but what I really don't like are the error messages that I get from
g++.
g++ error messages are often just not helpful.
Sometimes I just take the line number of the error and try to figure
out myself what might be wrong. Or I just remember this error message
and know already: if g++ says error X it really means error Y.
For example, take the following code:
#include <iostream>
class Interface{
public:
virtual std::string &getText() const = 0;
};
class Implementation : public Interface{
std::string text;
public:
Implementation::Implementation(std::string text):text(text){}
std::string &getText() const{
return text;
}
};
bash-2.05b$ g++ -c test.cpp
test.cpp: In member function `virtual std::string&
Implementation::getText()
const':
test.cpp:13: could not convert `this->Implementation::text' to
`std::string&'
The return type of getText() must not be std::string, but const
std::string. But why doesn't g++ just say that? It could say: "Could
not return reference to this->... from a const method"...
For beginners, it's also intimidating to get an error message that
fills several screens from the STL usage
std::vector<std::string> test;
std::cout << test;
The whole "candidates are..." list with 26 entries is anyway
unreadable... There should be a better, more readable way to indicate
an error.
Markus