Ez miért nem fordul le? C++
//main.cpp
#include<iostream>
#include<string>
using std::cout;
using std::string;
template<class T1, const unsigned short size = 11> class cProba{
public:
cProba(const T1);
~cProba();
T1 operator[](const unsigned short)const;
private:
T1 i_data[size];
protected:
};
template<class T1, const unsigned short size> cProba<T1, size>::cProba(const T1 data){
for(unsigned short i = 0; i < size; ++i)
this->i_data[i] = data;
}
template<class T1, const unsigned short size> cProba<T1, size>::~cProba() {}
template<class T1, const unsigned short size> T1 cProba<T1, size>::operator[](const unsigned short idx)const {return this->i_data[idx];}
template<int data, unsigned short size> class cIntProba: cProba<int, size>{
public:
cIntProba();
~cIntProba();
private:
protected:
};
template<int data, unsigned short size> cIntProba<data, size>::cIntProba(): cProba<int, size>(data) {}
template<int data, unsigned short size> cIntProba<data, size>::~cIntProba() {}
int main(){
cProba<unsigned short, 8> Proba1(8);
cProba<string, 4> Proba2("Welcome");
cIntProba<18, 14> IntProba;
cout << Proba1[0] << '\n'
<< Proba2[3] << '\n'
<< IntProba[13];
return 0;
}
Hibaüzi:
'T1 cProba<T1, size>::operator[](short unsigned int) const [with T1 = int; short unsigned int size = 14u]' is inaccessible
'cProba<int, 14u>' is not an accessible base of 'cIntProba<18, 14u>'
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!