This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Placing Eigen Variables as members in a class

Tags: None
(comma "," separated)
mcprakash
Registered Member
Posts
2
Karma
0
Hi Everyone
I just thought of placing my Eigen data-types as members inside a class. I am using visual studio to do the compiling. It is giving invalid data type but when I place the same in main() I do not get any errors. The exact error is "Error:Expected a type specifier"
Here is the code I am using

Code: Select all
class landmark
{
   Quaternionf orient(1, 0, 0, 0);
};
void main()
{
  Quaternionf orient(1, 0, 0, 0);
}


Please help me out.

Chandra :)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This is not how member variables are initialized in C++. You need a constructor:

Code: Select all
class landmark
{
public:
   landmark()
    : orient(1, 0, 0, 0)
  {
  }
protected:
  Quaternionf orient;
};


Please, open a book on C++ !


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]