I am getting this error when I try to print
Error C3867 'Carta::mostrar': non-standard syntax; use '&' to create a pointer to member
Carta.h
using namespace System;
ref class Carta
{
private:
String^ cara;
String^ palo;
public:
Carta();
Carta(String^ pCara, String^ pPalo);
String^ mostrar();
};
main.cpp
#include "Carta.h"
#include <stdio.h>
using namespace System;
using namespace System::Windows::Forms;
[STAThread]
int main(array<String^>^ args) {
Carta^ nueva = gcnew Carta("1", "Diamantes");
Console::WriteLine(nueva->mostrar); //Error here
}
Console::WriteLine(nueva->mostrar); //Error here
You are trying to access a member of nueva
object instead to call a method of this object. mostrar
is a method, not a property. Try to change to:
Console::WriteLine(nueva->mostrar());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.