Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
using my template class
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
ArbolOne  
View profile  
 More options Sep 28 2012, 9:23 pm
Newsgroups: gnu.g++.help
From: ArbolOne <Arbol...@gmail.com>
Date: Fri, 28 Sep 2012 18:23:12 -0700 (PDT)
Local: Fri, Sep 28 2012 9:23 pm
Subject: using my template class
template <class T, const int> class Data {
private:
    T data;
    int id;
public:
    Data();
    Data(T, const int);
    virtual ~Data();
};

template <class T, const int x>
Data<T, x>::Data() {}

template <class T, const int x>
Data<T, x>::Data(T _data, const int _id) {
    this->data = _data;
    this->id = _id;

}

template <class T, const int x>
Data<T, x>::~Data() {}

template <class T, const int x>
Data<T, x>::Data(const Data& other) {
    //copy ctor

}

int main(){
    jme::Data <std::string, const int> d("data", 1);
    std::cout << "Hello world!" << std::endl;
    return 0;

}

The class above compiles, but when trying to use it in the main() function, I get this error:

-------------- Build: Debug in data ---------------

Compiling: main.cpp
C:\...\main.cpp: In function 'int main()':
C:\...\main.cpp:8: error: type/value mismatch at argument 2 in template parameter list for 'template<class T, int <anonymous> > class jme::Data'
C:\...\main.cpp:8: error:   expected a constant of type 'int', got 'const int'
C:\...\main.cpp:8: error: invalid type in declaration before '(' token
C:\...\main.cpp:8: error: initializer expression list treated as compound expression
C:\...\main.cpp:8: warning: left-hand operand of comma has no effect
C:\...\main.cpp:8: warning: unused variable 'd'
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 2 warnings

I am bit confused as to how to use a class like that.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »