Solved

Template question. I really do not understand what this wants....

Posted on 2006-11-06
3
218 Views
Last Modified: 2010-04-01
OK. I have a Template....
template<typename T>        

class LookupTable2
{
  public:
    LookupTable2 (void);
 
    unsigned int getRows (void) const;    

 private:
    std::vector<std::vector<T> > table2_; ///< Create table object.
 };

Then I have another class that inherits the above....

};

#include "LookupTable2.h"

#include <iostream>
#include <vector>
#include <cmath>
template<typename T>            

class LookupTable3 : public LookupTable2 <T>
{
  public:
    LookupTable3<T> (void);
    void printAttributes (void);
 
  private:
    std::vector<LookupTable2<T> > table3_;  // Create table object.
 
};


Then I have a main() in a driver

#include <iostream>

#include "LookupTable3.h"
using namespace std;


int main (void)
{
  unsigned int nRow, nCol;

  LookupTable2<float> table2iv();
   
  table2iv.getColumns();

  LookupTable3<float> table3iv();

  table3iv.printAttributes();

  return 0;
}


I am getting an error in both

  table2iv.getColumns();

  LookupTable3<float> table3iv();

in the main. The error is   error C2228: left of '.getColumns' must have class/struct/union type

What is this asking. I do not understand.....Can some one tell me what?
0
Comment
Question by:prain
3 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 75 total points
ID: 17885272
>   LookupTable2<float> table2iv();
 
This is declaring a function that returns a LookupTable2<float> object, it is not declaring an object and calling the default constructor.

Get rid of the ()'s:

  LookupTable2<float> table2iv;
  LookupTable3<float> table3iv;

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question