Solved

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

Posted on 2006-11-06
3
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

  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 …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

626 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