我的习惯 class 不想进入容器
my custom class doesn't want to go into a container
我有我的class个人。
#pragma once
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
using namespace std;
using namespace System;
public ref class Personne
{
private:
String ^_login;
String ^_pwd;
int _age;
public:
Personne() {}
Personne(String ^login, String ^pwd, int age) : _login(login), _pwd(pwd), _age(age) {}
property String ^Login
{
String ^ get() { return _login; }
void set(String ^value) { _login = value; }
}
property String ^Pwd
{
String^ get() { return _pwd; }
void set(String ^value) { _pwd = value; }
}
property int Age
{
int get() { return _age; }
void set(int value) { _age = value; }
}
};
当我尝试将它放入任何类型的容器中时,我收到 30 条左右的错误,如下所示:
“*”:不可能在类型 'Personne' 上使用此间接寻址
'&':不可能在类型 'Personne'
上使用此间接寻址
当我像这样声明一个容器时,这一切都会发生
vector<Personne> mesPersonnes;
有人知道为什么会发生这种情况以及如何解决吗?
作为初学者 C++ 程序员,我没有注意到这是一个 CLI class。与本机 C++ 不兼容。
与原生 C++ 容器不兼容。
我有我的class个人。
#pragma once
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
using namespace std;
using namespace System;
public ref class Personne
{
private:
String ^_login;
String ^_pwd;
int _age;
public:
Personne() {}
Personne(String ^login, String ^pwd, int age) : _login(login), _pwd(pwd), _age(age) {}
property String ^Login
{
String ^ get() { return _login; }
void set(String ^value) { _login = value; }
}
property String ^Pwd
{
String^ get() { return _pwd; }
void set(String ^value) { _pwd = value; }
}
property int Age
{
int get() { return _age; }
void set(int value) { _age = value; }
}
};
当我尝试将它放入任何类型的容器中时,我收到 30 条左右的错误,如下所示: “*”:不可能在类型 'Personne' 上使用此间接寻址 '&':不可能在类型 'Personne'
上使用此间接寻址当我像这样声明一个容器时,这一切都会发生
vector<Personne> mesPersonnes;
有人知道为什么会发生这种情况以及如何解决吗?
作为初学者 C++ 程序员,我没有注意到这是一个 CLI class。与本机 C++ 不兼容。
与原生 C++ 容器不兼容。