Solved

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

Posted on 2006-11-06
3
187 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now