473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

illegel indirecion

I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
{
float x,y,c, z;

cout<<" Enter the Center Point of the circle, X-Axis: " ;
cin>> x ;

cout<<endl;
cout<<" Enter the Center Point of the circle, Y-Axis: " ;
cin>> y ;
cout<<" Enter the Color of that point: " ;
cin>> c ;

cout<<" Enter the radius of the circle: " ;
cin>> z;
cout<<endl;

Circle p1( (x,y,c),z);
a[*count_circle].SetArea(p1);
}
my class circle:

class Circle: public Shape
{
public:
Circle(){};
Circle(Point p, float r) : Shape(p) {radius = r;
cout<<"radius :" << radius; }

void SetArea(Circle) {area= PI * ( pow(radius,2) ); }
float GetArea(){ return area; }

private:
float radius;
float area;

};
Jul 22 '05 #1
7 1687
MiKy wrote:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle) <snip> a[*count_circle].SetArea(p1);
}

<snip>

count_circle is not a pointer, so you can't dereference it.

- Pete
Jul 22 '05 #2
Dan

"MiKy" <XY*@bam.com> wrote in message
news:pM**************@news20.bellglobal.com...
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
{
float x,y,c, z;

cout<<" Enter the Center Point of the circle, X-Axis: " ;
cin>> x ;

cout<<endl;
cout<<" Enter the Center Point of the circle, Y-Axis: " ;
cin>> y ;
cout<<" Enter the Color of that point: " ;
cin>> c ;

cout<<" Enter the radius of the circle: " ;
cin>> z;
cout<<endl;

Circle p1( (x,y,c),z);
a[*count_circle].SetArea(p1);
}
my class circle:

class Circle: public Shape
{
public:
Circle(){};
Circle(Point p, float r) : Shape(p) {radius = r;
cout<<"radius :" << radius; }

void SetArea(Circle) {area= PI * ( pow(radius,2) ); }
float GetArea(){ return area; }

private:
float radius;
float area;

Sorry my brother played around with my account. Its me Dan asking this
question.

.... a better program from the past couple of days ago.


Jul 22 '05 #3
MiKy wrote:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
How is a an array? CreateCircle(Circle a[], ... )
{
float x,y,c, z;

cout<<" Enter the Center Point of the circle, X-Axis: " ;
cin>> x ;

cout<<endl;
cout<<" Enter the Center Point of the circle, Y-Axis: " ;
cin>> y ;
cout<<" Enter the Color of that point: " ;
cin>> c ;

cout<<" Enter the radius of the circle: " ;
cin>> z;
cout<<endl;

Circle p1( (x,y,c),z);
a[*count_circle].SetArea(p1);
}
my class circle:

class Circle: public Shape
{
public:
Circle(){};
Circle(Point p, float r) : Shape(p) {radius = r;
cout<<"radius :" << radius; }

void SetArea(Circle) {area= PI * ( pow(radius,2) ); }
float GetArea(){ return area; }

private:
float radius;
float area;

};


Jul 22 '05 #4

"markspace" <ma*********@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
MiKy wrote:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)


How is a an array? CreateCircle(Circle a[], ... )


a is not an array in your code either. In a function parameter 'Circle a[]'
is exactly the same as 'Circle *a'. Arrays cannot be parameters in C or C++.

john
Jul 22 '05 #5
MiKy posted:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
{
float x,y,c, z;

cout<<" Enter the Center Point of the circle, X-Axis: " ;
cin>> x ;

cout<<endl;
cout<<" Enter the Center Point of the circle, Y-Axis: " ;
cin>> y ;
cout<<" Enter the Color of that point: " ;
cin>> c ;

cout<<" Enter the radius of the circle: " ;
cin>> z;
cout<<endl;

Circle p1( (x,y,c),z);
a[*count_circle].SetArea(p1);
}


I can only presume that a points to the start of an array of Circle*. If
so, replace:

a[*count_circle].SetArea(p1);

with

a[count_circle]->SetArea(p1);

or even:

*(a[count_circle]).SetArea(p1);

If a points to an array of Circle,
a[count_circle].SetArea(p1);

-JKop


-JKop
Jul 22 '05 #6
JKop wrote:

MiKy posted:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
{
float x,y,c, z;

cout<<" Enter the Center Point of the circle, X-Axis: " ;
cin>> x ;

cout<<endl;
cout<<" Enter the Center Point of the circle, Y-Axis: " ;
cin>> y ;
cout<<" Enter the Color of that point: " ;
cin>> c ;

cout<<" Enter the radius of the circle: " ;
cin>> z;
cout<<endl;

Circle p1( (x,y,c),z);
a[*count_circle].SetArea(p1);
}


I can only presume that a points to the start of an array of Circle*.


.... then the first argument to this function would be of type Circle**.
Since it is not you can deduce that a does not point to the start of an array
of Circle*
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #7
Karl Heinz Buchegger <kb******@gascad.at> wrote in message news:<40***************@gascad.at>...
JKop wrote:

MiKy posted:
I am getting this error:
Illegal indirection at line : a[*count_circle].SetArea(p1);
Is it possible to set an object in an array like I am trying to do ?

void CreateCircle(Circle* a, int count_circle)
{


I can only presume that a points to the start of an array of Circle*.


... then the first argument to this function would be of type Circle**.
Since it is not you can deduce that a does not point to the start of an array
of Circle*


A Circle* can most definitely point to an array of Circles. A Circle**
will actually point to an array of pointers to circles. Since you have
an array of pointers, you can then actually have any object derived from
Circle to enable you to get polymorphic behaviour.

But if all you have are actual circles, an array of actual instances of
Circles would be represented by Circle*.

samuel
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: David Eng | last post by:
In replying to P.J. Plauger (...
2
by: Janaka | last post by:
We have managed to lock down 99% of the application errors occurring in our asp.net sites. The only errors which occur on a regular basis now are viewstate errors. We have disabled viewstate on...
0
by: funnyjokar1 | last post by:
timeoff, people! funny joke here :))) Girls vs boys. Girls' English. 1.Yes. = No. 2.No. = Yes.
3
by: erajaysharma | last post by:
This issue is in Vista. I used XML files(one for DLLs, other for EXEs) ane embeded them in my EXEs and all DLLs ....actually i want to spawn a third party setup from found new hardware...but an...
0
by: ryanmhuc | last post by:
I have a table (depth as int, name as varchar). If I run the following query I get NO ERROR SELECT CONCAT(REPEAT(' ', 2) , display_name) as name FROM test If I run this: SELECT...
9
by: bradyounie | last post by:
I have an application that displays a user-supplied image as part of what the app does. I need to include a PDF as a supported image type. Is there a PictureBox or some control that can show PDFs?...
5
by: lucindaa | last post by:
Hi Friends, i have 6 projects in my project, unfortunatelly one of my project is deleted i could not get it back but i have the dll of that project so i want to know is there any way to retrive the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.