我正在 Windows Phone 上开发应用程序。在 VS 模板项目中,有一个类 SampleDataSource 实现了应用程序的数据层。在类似的类中,我添加了一个具有我自己类类型的属性 (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文件里)。
关于c++ - Windows Universal App 8.1 C++/自定义类属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28255828/