Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [C++] my custom class doesn't want to go into a container.
New Posts  All Forums:Forum Nav:

[C++] my custom class doesn't want to go into a container.

post #1 of 8
Thread Starter 
i have my class Personne.
Code:
#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; }
        }
};

when i try to put it in any type of container i get a 30 or so errors all like this :
'*' : impossible to use this indirection on the type 'Personne'
'&' : impossible to use this indirection on the type 'Personne'

this all happens when i declare a container, like this
Code:
vector<Personne> mesPersonnes;

would anyone have any idee why this happens and how to resolve it?
post #2 of 8
Quote:
Originally Posted by lolplayer101 View Post

i have my class Personne.
Code:
#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; }
        }
};

when i try to put it in any type of container i get a 30 or so errors all like this :
'*' : impossible to use this indirection on the type 'Personne'
'&' : impossible to use this indirection on the type 'Personne'

this all happens when i declare a container, like this
Code:
vector<Personne> mesPersonnes;

would anyone have any idee why this happens and how to resolve it?

I would recommend you Stackoverflow.
post #3 of 8
Thread Starter 
i will try there, thank you.
post #4 of 8
have you tried using it as a pointer instead ?
Code:
vector<Personne> *ptr;

Edited by ondoy - 7/5/16 at 3:18am
post #5 of 8
I'd recommend you stay away from Microsoft's butchered managed c++ and learn actual c++ first.
Lightbringer
(17 items)
 
Naranek
(10 items)
 
pfSense
(7 items)
 
CPUMotherboardGraphicsGraphics
5960x 4.5Ghz asus x99 deluxe NVidia 980 GTX Nvidia 980 GTX 
RAMHard DriveOptical DriveCooling
Corsair Vengeance Intel 750 M.2 SSD 1.2TB LG Blue Ray Koolance 380i 
CoolingCoolingOSMonitor
EK-FC980 EK-FC980 Windows 8.1 x64 Asus Rog Swift 
MonitorKeyboardPowerCase
Dell u3011 Logitech g710+ Seasonic 860 Fractal design arc xl 
Mouse
Logitech g700 
CPUMotherboardGraphicsRAM
Intel 5820k ASRock X99E-ITX/ac Gigabyte GTX 960 Windforce GSkill Ares 16 GB 2400 
Hard DriveHard DriveOptical DriveOS
Samsung 950 pro 256 Samsung 840 500GB UJ-265 Panasonic Windows 10 
PowerCase
Silverstone SFX-L 500W Silverstone Mini ITX ML07B 
CPUMotherboardRAMCooling
Intel core i3 2120 portwell wade 8012 Gskill Noctua NH-L9i 
OSPowerCase
pfSense picoPSU-160-XT  MITXPC MX500 
  hide details  
Reply
Lightbringer
(17 items)
 
Naranek
(10 items)
 
pfSense
(7 items)
 
CPUMotherboardGraphicsGraphics
5960x 4.5Ghz asus x99 deluxe NVidia 980 GTX Nvidia 980 GTX 
RAMHard DriveOptical DriveCooling
Corsair Vengeance Intel 750 M.2 SSD 1.2TB LG Blue Ray Koolance 380i 
CoolingCoolingOSMonitor
EK-FC980 EK-FC980 Windows 8.1 x64 Asus Rog Swift 
MonitorKeyboardPowerCase
Dell u3011 Logitech g710+ Seasonic 860 Fractal design arc xl 
Mouse
Logitech g700 
CPUMotherboardGraphicsRAM
Intel 5820k ASRock X99E-ITX/ac Gigabyte GTX 960 Windforce GSkill Ares 16 GB 2400 
Hard DriveHard DriveOptical DriveOS
Samsung 950 pro 256 Samsung 840 500GB UJ-265 Panasonic Windows 10 
PowerCase
Silverstone SFX-L 500W Silverstone Mini ITX ML07B 
CPUMotherboardRAMCooling
Intel core i3 2120 portwell wade 8012 Gskill Noctua NH-L9i 
OSPowerCase
pfSense picoPSU-160-XT  MITXPC MX500 
  hide details  
Reply
post #6 of 8
Quote:
Originally Posted by lolplayer101 View Post

i have my class Personne.
Code:
#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; }
        }
};

when i try to put it in any type of container i get a 30 or so errors all like this :
'*' : impossible to use this indirection on the type 'Personne'
'&' : impossible to use this indirection on the type 'Personne'

this all happens when i declare a container, like this
Code:
vector<Personne> mesPersonnes;

would anyone have any idee why this happens and how to resolve it?

is this your first coding language?
I started with Java first...
post #7 of 8
Thread Starter 
Quote:
Originally Posted by ondoy View Post

have you tried using it as a pointer instead ?
Code:
vector<Personne> *ptr;
this doesn't work with managed code.
Quote:
Originally Posted by Dmitriy View Post

I'd recommend you stay away from Microsoft's butchered managed c++ and learn actual c++ first.
unfortunately i despretly need this in order to serialize the classes into xml. but i am of the same opinion that it would have been better to start with normal C++.
Quote:
Originally Posted by erso44 View Post

is this your first coding language?
I started with Java first...
this is my 3rd. i have been a C# and Java person all my live but this language is driving me nuts. never have i seen a language so unnecessarily complicated in my life...
post #8 of 8
Quote:
Originally Posted by lolplayer101 View Post

this doesn't work with managed code.
unfortunately i despretly need this in order to serialize the classes into xml. but i am of the same opinion that it would have been better to start with normal C++.
this is my 3rd. i have been a C# and Java person all my live but this language is driving me nuts. never have i seen a language so unnecessarily complicated in my life...

That pointer thing didn't work at all as it made no sense. Think about different ways to achieve serialization as too many bad decisions are made in this exact way. Believe me you can do anything in C++. It's much better to use some 3rd party library in standard language than to use something like managed C++ only because you need some functionality, you save few days of work and then loose much more down the road. I can't help you with managed C++ but in normal C++ you class won't work in a vector if you fail to make it copy constructable for example. Vector assumes certain behavior I'm sure it's the same in managed C++.
Lightbringer
(17 items)
 
Naranek
(10 items)
 
pfSense
(7 items)
 
CPUMotherboardGraphicsGraphics
5960x 4.5Ghz asus x99 deluxe NVidia 980 GTX Nvidia 980 GTX 
RAMHard DriveOptical DriveCooling
Corsair Vengeance Intel 750 M.2 SSD 1.2TB LG Blue Ray Koolance 380i 
CoolingCoolingOSMonitor
EK-FC980 EK-FC980 Windows 8.1 x64 Asus Rog Swift 
MonitorKeyboardPowerCase
Dell u3011 Logitech g710+ Seasonic 860 Fractal design arc xl 
Mouse
Logitech g700 
CPUMotherboardGraphicsRAM
Intel 5820k ASRock X99E-ITX/ac Gigabyte GTX 960 Windforce GSkill Ares 16 GB 2400 
Hard DriveHard DriveOptical DriveOS
Samsung 950 pro 256 Samsung 840 500GB UJ-265 Panasonic Windows 10 
PowerCase
Silverstone SFX-L 500W Silverstone Mini ITX ML07B 
CPUMotherboardRAMCooling
Intel core i3 2120 portwell wade 8012 Gskill Noctua NH-L9i 
OSPowerCase
pfSense picoPSU-160-XT  MITXPC MX500 
  hide details  
Reply
Lightbringer
(17 items)
 
Naranek
(10 items)
 
pfSense
(7 items)
 
CPUMotherboardGraphicsGraphics
5960x 4.5Ghz asus x99 deluxe NVidia 980 GTX Nvidia 980 GTX 
RAMHard DriveOptical DriveCooling
Corsair Vengeance Intel 750 M.2 SSD 1.2TB LG Blue Ray Koolance 380i 
CoolingCoolingOSMonitor
EK-FC980 EK-FC980 Windows 8.1 x64 Asus Rog Swift 
MonitorKeyboardPowerCase
Dell u3011 Logitech g710+ Seasonic 860 Fractal design arc xl 
Mouse
Logitech g700 
CPUMotherboardGraphicsRAM
Intel 5820k ASRock X99E-ITX/ac Gigabyte GTX 960 Windforce GSkill Ares 16 GB 2400 
Hard DriveHard DriveOptical DriveOS
Samsung 950 pro 256 Samsung 840 500GB UJ-265 Panasonic Windows 10 
PowerCase
Silverstone SFX-L 500W Silverstone Mini ITX ML07B 
CPUMotherboardRAMCooling
Intel core i3 2120 portwell wade 8012 Gskill Noctua NH-L9i 
OSPowerCase
pfSense picoPSU-160-XT  MITXPC MX500 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [C++] my custom class doesn't want to go into a container.