Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9000225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:17:04+00:00 2026-06-16T00:17:04+00:00

I have a class CPolygon which is derived from the class CElement . [

  • 0

I have a class CPolygon which is derived from the class CElement. [ I’m making use of polymorphism here].

 class CElement : public CObject
 {
 public:
virtual ~CElement();
virtual void Draw(CDC* pDC){};
CPoint vertices[11];

 protected:

CElement();

 };

 class CPolygon : public CElement
 {
 public:
CPolygon(CPoint mFirstPoint,CPoint mSecondPoint);
~CPolygon(void);
 virtual void Draw(CDC* pDC);                 


 protected:
CPoint mStartPoint;
CPoint mEndPoint;
CPolygon(void);


 };

When I try to assign an array to the member vertices of a CElement object, I get the error: expression must be a modifiable Lvalue

 CElement* a = new CPolygon(mFirstPoint,mSecondPoint);
  a->vertices=vertices;        //here!!

Why doesn’t this work??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:17:04+00:00Added an answer on June 16, 2026 at 12:17 am

    Because a->vertices is not a modifiable Lvalue… You can’t assign arrays in C++, you can only assign specific elements or do a copy.

    If you know the size to be 11, I’d use a std::array (or std::vector, for flexibility) instead of a C-style array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have: class BASE{ public: virtual void func1() = 0; }; Then I have
I have class Lazy which lazily evaluates an expression: public sealed class Lazy<T> {
I have class two ViewModels //both IViewModel1 and IViewModel2 inherit from IViewModel public class
I have class B derived from class A. I call copy constructor that I
I have class which handles packages: typedef void (*FCPackageHandlerFunction)(FCPackage*); class FCPackageHandlers{ ... void registerHandler(FCPackage::Type
I have class A derived from a Windows.Form class, using the VS2008 designer. When
I have class A: public class ClassA<T> Class B derives from A: public class
I have Class and Student objects. Both have collection of another as property. Which
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
I have class with back reference: public class Employee : Entity { private string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.