我正在尝试在另一个对象中创建一个对象数组,并决定数组的大小。
当我尝试将“obj2T”分配给“obj2”时,为什么会出现错误?
Pastebin代码链接:https://pastebin.com/kujujP5N
在另一个对象中创建对象数组并确定数组大小的正确语法是什么?
#include <iostream>
using namespace std;
class classe2
{
public:
classe2();
protected:
private:
};
class classe1
{
public:
classe1(int value);
void setClasse()
{
classe2 obj2T[grandezza];
obj2=obj2T;
}
protected:
private:
const int grandezza;
classe2 obj2[];
};
int main()
{
cout << "Hello World!" << endl;
return 0;
}
错误:
C:\cppProjects\project\main.cpp||In member function 'void classe1::setClasse()'
C:\cppProjects\project\main.cpp|22|error: incompatible types in assignment of 'classe2 [((classe1*)this)->classe1::grandezza]' to 'classe2 [0]'
答案 0 :(得分:1)
正确的语法是
public static final String TABLE_NAME = "'Vehicle entry'";
public static final String COLUMN_REGISTRATION_NUMBER = "'Registration number'";
public static final String COLUMN_OWNER_NAME = "'Owner name'";
public static final String COLUMN_TYPE = "'Vehicle type'";