Topic: nested vectors
Author: jpotter@falcon.lhup.edu (John Potter)
Date: 1997/08/18 Raw View
Peter Niessen <niessen@physik.rwth-aachen.de> wrote:
: I'd like to have a vector of vectors:
: #include <String.h>
: #include <vector.h>
: class TConf
: {
: private:
: struct Config
: {
: int Port;
: struct Command
: {
: String ComString;
: // other stuff
: }
assumed ;
: vector<Command> CommandList;
: }
assumed ;
: vector<Config> ConfigList;
: public:
: when compiling, I get (g++ on Linux)
: /tmp/cca188161.o: In function `TConf::Config::operator=(TConf::Config
: const &)':
: /tmp/cca188161.o(.text+0x1bb8): undefined reference to
: `vector<TConf::Config::Command>::operator=(vector<TConf::Config::Command>
: const &)'
I think you have a compiler bug. Somewhere in your code, there is a
statement
ConfigList[i] = ConfigList[j];
or something else that requires Config.operator=(). Since Config does
not have an operator= defined, the compiler must generate one as:
Config& operator= (Config const& rhs) {
Port = rhs.Port;
CommandList = rhs.CommandList;
return *this;
}
It should notice the second line which is the vector<>.operator= and
instantiate it. It doesn't seem to notice, leading to the link error.
If I add the above code to the struct Config definition, g++ gets the
rest correct.
John
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Peter Niessen <niessen@physik.rwth-aachen.de>
Date: 1997/08/17 Raw View
I'd like to have a vector of vectors:
#include <String.h>
#include <vector.h>
class TConf
{
private:
struct Config
{
int Port;
struct Command
{
String ComString;
// other stuff
}
vector<Command> CommandList;
}
vector<Config> ConfigList;
public:
int ReadCfg (String *CfgFile);
...
}
when compiling, I get (g++ on Linux)
/tmp/cca188161.o: In function `TConf::Config::operator=(TConf::Config
const &)':
/tmp/cca188161.o(.text+0x1bb8): undefined reference to
`vector<TConf::Config::Command>::operator=(vector<TConf::Config::Command>
const &)'
What is the remedy for that?
Cheers, Peter.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]