Windows 通用应用程序 8.1 C++/自定义 Class 属性
Windows Universal App 8.1 C++ / Custom Class Property
我正在 windows phone 上开发应用程序。在 VS 模板项目中有一个 class SampleDataSource 实现了应用程序的数据层。在类似的 class 中,我用我自己的 class 类型添加了一个 属性 (AccountData^ Account) 并得到以下错误 LNK2001。谁能帮帮我?
[Windows::UI::Xaml::Data::Bindable]
public ref class AccountDataSource sealed
{
public:
property Windows::Foundation::Collections::IObservableVector<AccountMessage^>^ Messages
{
Windows::Foundation::Collections::IObservableVector<AccountMessage^>^ get();
}
property AccountData^ Account
{
AccountData^ get();
}
internal:
AccountDataSource();
static concurrency::task<AccountData^> GetAccount(Platform::String^ id);
private:
AccountData^ _account;
Platform::Collections::Vector<AccountMessage^>^ _messages;
static AccountDataSource^ _accountDataSource;
};
错误:
Error 1 error LNK2001: unresolved external symbol "public: virtual class WindowsUniversalApp::Data::AccountData ^ __cdecl WindowsUniversalApp::Data::AccountDataSource::Account::
[WindowsUniversalApp::Data::__IAccountDataSourcePublicNonVirtuals::Account]::get(void)" (?get@?QAccount@__IAccountDataSourcePublicNonVirtuals@Data@WindowsUniversalApp@@1AccountDataSource@34@U$AAAP$AAVAccountData@34@XZ)
C:\Users\xxx\Documents\Projects\Universal\WindowsUniversalApp\WindowsUniversalApp\WindowsUniversalApp.Windows\AccountDataSource.obj WindowsUniversalApp.Windows
谢谢,
您说过 Messages
是 属性 和 getter,但您没有在任何地方定义 getter。你需要一个函数体:
property longTypeName Messages { longTypeName get() { return _messages; } }
(当然你也可以放在CPP文件里)
我正在 windows phone 上开发应用程序。在 VS 模板项目中有一个 class SampleDataSource 实现了应用程序的数据层。在类似的 class 中,我用我自己的 class 类型添加了一个 属性 (AccountData^ Account) 并得到以下错误 LNK2001。谁能帮帮我?
[Windows::UI::Xaml::Data::Bindable]
public ref class AccountDataSource sealed
{
public:
property Windows::Foundation::Collections::IObservableVector<AccountMessage^>^ Messages
{
Windows::Foundation::Collections::IObservableVector<AccountMessage^>^ get();
}
property AccountData^ Account
{
AccountData^ get();
}
internal:
AccountDataSource();
static concurrency::task<AccountData^> GetAccount(Platform::String^ id);
private:
AccountData^ _account;
Platform::Collections::Vector<AccountMessage^>^ _messages;
static AccountDataSource^ _accountDataSource;
};
错误:
Error 1 error LNK2001: unresolved external symbol "public: virtual class WindowsUniversalApp::Data::AccountData ^ __cdecl WindowsUniversalApp::Data::AccountDataSource::Account::
[WindowsUniversalApp::Data::__IAccountDataSourcePublicNonVirtuals::Account]::get(void)" (?get@?QAccount@__IAccountDataSourcePublicNonVirtuals@Data@WindowsUniversalApp@@1AccountDataSource@34@U$AAAP$AAVAccountData@34@XZ)
C:\Users\xxx\Documents\Projects\Universal\WindowsUniversalApp\WindowsUniversalApp\WindowsUniversalApp.Windows\AccountDataSource.obj WindowsUniversalApp.Windows
谢谢,
您说过 Messages
是 属性 和 getter,但您没有在任何地方定义 getter。你需要一个函数体:
property longTypeName Messages { longTypeName get() { return _messages; } }
(当然你也可以放在CPP文件里)