Unrecognized template syntax

L

l h

I'm looking over some code and I see something of the nature of the
following:

int stat = TemplateClass<type1, type2,
type3>::memberMethod(arg1);

type1, type2, & type3 are pointers to other classes/interfaces. arg1
may or may not be a pointer to a class. There is a constructor for
TemplateClass that takes different pointers than the ones above.

TemplateClass is not static and neither are the member methods being
called.

Could someone please explain exactly what I'm looking at?

Thanks.

Les
 
V

Victor Bazarov

l said:
I'm looking over some code and I see something of the nature of the
following:

int stat = TemplateClass<type1, type2,
type3>::memberMethod(arg1);

type1, type2, & type3 are pointers to other classes/interfaces.

Pointers? As in

SomeType *type1 = &someObject;

?
> arg1
may or may not be a pointer to a class.
OK

> There is a constructor for
TemplateClass that takes different pointers than the ones above.

The syntax above has nothing to do with constructors.
TemplateClass is not static and neither are the member methods being
called.

Could someone please explain exactly what I'm looking at?

If, as you say, 'memberMethod' is not a static member function, can it
be that the template is the base class of the class from which you're
calling this 'memberMethod'?

template<class A> class T {
protected:
int memberMethod(...);
};

template<class U> class D : T<U> {
void foo() {
int blah = T<U>::memberMethod("blah");
}
};


<shrug> Post more code.

V
 
D

Daniel Pitts

I'm looking over some code and I see something of the nature of the
following:

int stat = TemplateClass<type1, type2,
type3>::memberMethod(arg1);

type1, type2,& type3 are pointers to other classes/interfaces. arg1
may or may not be a pointer to a class. There is a constructor for
TemplateClass that takes different pointers than the ones above.

TemplateClass is not static and neither are the member methods being
called.

Could someone please explain exactly what I'm looking at?

Thanks.

Les
Perhaps posting more of your code would help. I see this as a possible
alternative to your explanation:

int TemplateClass = 0;
int type1 = 1;
int type2 = 2;
int type3 = 3;
int arg1 = 4;

int memberMethod(int) {
return 5;
}

int main() {
int stat;

stat = TemplateClass<type1, type2, type3>::memberMethod(arg1);
}


This is also one of the reasons I don't like C++.
 
L

l h

Perhaps posting more of your code would help.  I see this as a possible
alternative to your explanation:

int TemplateClass = 0;
int type1 = 1;
int type2 = 2;
int type3 = 3;
int arg1 = 4;

int memberMethod(int) {
    return 5;

}

int main() {
   int stat;

   stat = TemplateClass<type1, type2, type3>::memberMethod(arg1);

}

This is also one of the reasons I don't like C++.

I'll try and simplify more code to post, but what I'm trying to get at
is that if nothing is static, why isn't a instance of the class,
TemplateClass, being used to call memberMethod?

TemplateClass<type1, type2, type3> tcObj;
int stat = tcObj.memberMethod(arg1);

Les
 
L

l h

I'll try and simplify more code to post, but what I'm trying to get at
is that if nothing is static, why isn't a instance of the class,
TemplateClass, being used to call memberMethod?

           TemplateClass<type1, type2, type3> tcObj;
           int stat = tcObj.memberMethod(arg1);

Les

Okay. Looking at a lot more code than I had before and way to many COM
interfaces, TemplateClass is a base class to the class where the usage
I've shown is taking place.

Sorry for the confusion.

Les
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top