class A{
private:
int a;
public:
A() {a = 4;}
const int& random1() const {return a; }
//int& random2() const {return a; }
const int* random3() const {return &a;}
//int* random4() const {return &a;}
};
int main(){
A objA;
cout<<objA.random1()<<"\n";
cout<<*objA.random3()<<"\n";
}
random2() an...
Hi,
I'm trying to specialize the member function moment() only (not the hole class) like this:
template<class Derived, class T>
class AbstractWavelet {
public:
[...]
template<bool useCache>
const typename T::scalar moment(const int i, const int j) const {
return abstractWaveletSpecialization<Derived, T, useCache>::moment(sta...
Might be a basic question.Still i am eager to know it from this forum as i like the explanations given here.
In C++ some times i see members like below:
return_type Function_name( datatype parameter1, datatype parameter2 ) const
{ /*................*/}
what does this const type qualifier exact do over here.
...
I made the following program
#include <iostream>
#include <typeinfo>
template<class T>
struct Class
{
template<class U>
void display(){
std::cout<<typeid(U).name()<<std::endl;
return ;
}
};
template<class T,class U>
void func(Class<T>k)
{
k.display<U>();
}
int main()
{
Class<int> d;
func<in...
What the question says. In addition, is it possible to do this inline?
Here is a small example just to give an idea...
template<typename T>
class Foo {
public:
Foo() :z(0.0) {}
void do( const Foo<T> &f ) {
z = f.z;
}
// specialize 'do' for Foo<int>, possible inline?
private:
T z;
};
...
What are all the member-functions created by compiler for a class? Does that happen all the time? like destructor.
My concern is whether it is created for all the classes, and why is default constructor needed?
...
Is it possible (or relevant at all) to export member functions of a static library?
When I "dumpbin /EXPORTS" my .lib file I don't see any of my defined class members.
Linking to this lib file succeeds, but I use an external tool that fails to read non-exported symbols.
Also tried adding a .def file with no results.
...
Hello all, I think I've run into a (possible) VC6 (I know. It's what we use.) compiler error, but am open to the fact that I've just missed something dumb. Given the following code (It's just an example!):
#include <iostream>
// Class with template member function:
class SomeClass
{
public:
SomeClass() {};
template<class T>
T ge...
I get no matching member function error when i try to compile this code on my mingw32 compiler
#include <iostream>
using std::cout;
template <class T>
class Pattern
{
public:
Pattern(): element(){
cout<< "default c-tor";
}
Pattern(Pattern ©): element(copy.element){
cout<< "copy c-tor";
}
...
I am working on a template class Array, which accepts another template TRAITS as a parameter.
template <typename BASE, typename STRUCT>
class Traits {
public:
typedef BASE BaseType;
typedef STRUCT Struct;
// .. More here
};
template <class TRAITS>
class Array {
public:
typedef TRAI...
say there are 2 classes:
struct A{ int GetInt(){ return 10; } };
struct B{ int m; };
I want to use object of type A or B in following function
tempate< typename T >
int GetInt( const T & t )
{
//if it's A, I'll call: return t.GetInt();
//if its' B, I'll call: return t.m;
}
Now, because there are whole bunch of classes, some c...