Click here to Skip to main content
15,893,381 members
Home / Discussions / C#
   

C#

 
GeneralRe: OpenGL in C# and Visual Studio 2005/2008 Pin
harold aptroot3-Jan-10 6:25
harold aptroot3-Jan-10 6:25 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Pete O'Hanlon3-Jan-10 9:32
mvePete O'Hanlon3-Jan-10 9:32 
AnswerRe: OpenGL in C# and Visual Studio 2005/2008 Pin
Patrick Skelton3-Jan-10 22:31
Patrick Skelton3-Jan-10 22:31 
QuestionEvent Handler Pin
AlexB473-Jan-10 0:06
AlexB473-Jan-10 0:06 
AnswerRe: Event Handler Pin
DaveyM693-Jan-10 0:33
professionalDaveyM693-Jan-10 0:33 
GeneralRe: Event Handler Pin
AlexB473-Jan-10 4:05
AlexB473-Jan-10 4:05 
Questionword file Not lock...? Pin
koolprasad20032-Jan-10 23:48
professionalkoolprasad20032-Jan-10 23:48 
QuestionI'm Baffled Again Pin
Roger Wright2-Jan-10 21:49
professionalRoger Wright2-Jan-10 21:49 
While trying to create a Triangle class - a general purpose marker that accepts a location, size, and rotation angle - I keep running into access violations. I don't understand why.

The class declaration includes:

namespace ShapesLibrary
{
    class Triangle
    {
        //Class Variable Members
        private Point Anchor;
        private Point Vertex1;
        private Point Vertex2;
        private Point Vertex3;


It's only a partial list, but it shows the relevant details. The constructor for the class includes:

public Triangle(Point anchor, Int32 radius, float angle)
        {
            
            Anchor=anchor;
            Radius=radius;
            Angle=angle;
            Vertex1.X = Convert.ToInt32(Radius*Math.Cos(Angle));
            Vertex1.Y= Convert.ToInt32(Radius*Math.Sin(Angle));
            
            Vertex2.X = Convert.ToInt32(Radius*Math.Cos(Angle+120));
            Vertex2.Y= Convert.ToInt32(Radius*Math.Sin(Angle+120));
            
            Vertex3.X = Convert.ToInt32(Radius*Math.Cos(Angle+240));
            Vertex3.Y = Convert.ToInt32(Radius*Math.Sin(Angle+240));


So far, so good; no errors emitted thus far. Now, I don't want users recalculating where the vertices are, so I don't want these members to be public, but I do want them to be able to find them. I first added a 'get' accessor to each of them, but that created an error in the Constructor, telling me that VertexN is not a variable. So I added a group of member functions to read the values, to wit:

//Class Methods
        public Point GetVertex1
        {
                       
            return Vertex1;
        }
        public Point GetVertex2
        {
            return Vertex2;
        }
        public Point GetVertex3
        {
            return Vertex3;


Doing this generated errors that told me that a 'get' or 'set' accessor is required. Obviously I'm missing some important concept here. I thought that a private variable is accessible by all members of a class, and that I should be able to return such a value from a class method that is declared public. Apparently not...

What am I missing here?

"A Journey of a Thousand Rest Stops Begins with a Single Movement"

AnswerRe: I'm Baffled Again Pin
Richard MacCutchan2-Jan-10 22:00
mveRichard MacCutchan2-Jan-10 22:00 
AnswerRe: I'm Baffled Again Pin
Abhinav S2-Jan-10 22:06
Abhinav S2-Jan-10 22:06 
AnswerRe: I'm Baffled Again Pin
Rob Philpott2-Jan-10 22:17
Rob Philpott2-Jan-10 22:17 
GeneralRe: I'm Baffled Again Pin
Roger Wright4-Jan-10 1:46
professionalRoger Wright4-Jan-10 1:46 
AnswerRe: I'm Baffled Again Pin
DaveyM692-Jan-10 23:56
professionalDaveyM692-Jan-10 23:56 
QuestionRe: I'm Baffled Again Pin
Abhinav S3-Jan-10 0:03
Abhinav S3-Jan-10 0:03 
AnswerRe: I'm Baffled Again Pin
DaveyM693-Jan-10 0:28
professionalDaveyM693-Jan-10 0:28 
GeneralRe: I'm Baffled Again Pin
Rob Philpott3-Jan-10 0:35
Rob Philpott3-Jan-10 0:35 
GeneralRe: I'm Baffled Again Pin
DaveyM693-Jan-10 0:51
professionalDaveyM693-Jan-10 0:51 
GeneralRe: I'm Baffled Again Pin
OriginalGriff3-Jan-10 1:09
mveOriginalGriff3-Jan-10 1:09 
GeneralRe: I'm Baffled Again Pin
Abhinav S3-Jan-10 1:13
Abhinav S3-Jan-10 1:13 
GeneralRe: I'm Baffled Again Pin
OriginalGriff3-Jan-10 1:23
mveOriginalGriff3-Jan-10 1:23 
GeneralRe: I'm Baffled Again Pin
DaveyM693-Jan-10 1:15
professionalDaveyM693-Jan-10 1:15 
GeneralRe: I'm Baffled Again Pin
DaveyM693-Jan-10 1:14
professionalDaveyM693-Jan-10 1:14 
GeneralRe: I'm Baffled Again Pin
Rob Philpott3-Jan-10 1:20
Rob Philpott3-Jan-10 1:20 
GeneralRe: I'm Baffled Again Pin
OriginalGriff3-Jan-10 1:25
mveOriginalGriff3-Jan-10 1:25 
GeneralRe: I'm Baffled Again Pin
Rob Philpott3-Jan-10 1:35
Rob Philpott3-Jan-10 1:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.