Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

789 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