//// point.h
using namespace System::Drawing;


class point
{
protected:
int x;
int y;
Color col;

public:
point();
};
////point.cpp
#include "stdafx.h"
#include "point.h"

point::point()
{
x = 0;
y = 0;
col = Color::Blue;

}
///Error
c:\...\point.h(10) : error C3265: cannot declare a managed 'col' in an unmanaged 'point'
1> the value type may not contain members of managed types

Everything compiled without errors until I created the .cpp file. I'm almost sure it's a missing namespace or include, but i don't know which one. Help would be appreciated!

is Color part of using namespace System::Drawing; ? if not you need to include it in your point class. this is all i can get from this.

The prompt I received for this said to begin with the class point and those 3 data members (int x, int y, Color col), which means that Color isn't a class i'm supposed to create.. so I suppose it is part of System::Drawing .

I've used Color objects (a part of System::Drawing ) many times in other programs in Form1.h with no problems at all, but for some reason I can't get it to work here.

if I remove the using namespace line, I receive 7 more errors so I think that's a step in the right direction.

well i looked on my MSDN and from what i found there is a System.Drawing namespace. Could this be what it should be?

using namespace System.Drawing;

System.Drawing

The ones with the periods are the C# libraries System::Drawing is correct.

Can you post your point.h? If it is an unmanaged class (i.e. is not a ref or value class) you will probably not be able to incorporate the managed code (the .NET Color portion) with the unmanaged class.You can use it freely in Form1.h because Form inherits from System.

Thanks for the replies. Yes, my point class is unmanaged, and I didn't know how to make it managed until now. Below is the edit I made to point.h to get rid of that error, for those who are interested:

////point.h
using namespace System::Drawing;

public ref class cpoint   // Edited line
{
int x;
int y;
Color col;
		
public:		
cpoint();

I hadn't scrolled up far enough to get point.h so apologies for asking for you to post it again. Glad you got it working!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.