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

  • SEARCH
  • Home
  • 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 8764313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:00:19+00:00 2026-06-13T16:00:19+00:00

struct Set { int a; Set() : a(30){}; bool operator>( const Set& ref )

  • 0
struct Set
{
    int a;
    Set() : a(30){};
    bool operator>( const Set& ref ) const
    {
        return ref.a > this->a;
    };
};

int _tmain(int argc, _TCHAR* argv[])
{   
    vector<Set>m_set;
    m_set.push_back( (*(new Set)) );
    cout << m_set.at(0).a;
    delete &(m_set.at(0));
    if( &(m_set.at(0).a) )
        cout << "valid" << endl;

    return 0;
}

Why does it outputs valid, is deleting using this method invalid?

  • 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-13T16:00:20+00:00Added an answer on June 13, 2026 at 4:00 pm

    When you access an object that has been deleted the behavior is undefined. Anything can happen.

    EDIT: and, more to the point, when you delete an object that wasn’t created with new, the behavior is undefined. Anything can happen. That’s what the code here does.

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

Sidebar

Related Questions

struct Node { int value Node* next; } typedef List Node* const Set operator
There is struct like this. struct Address { int id; int set; char name[MAX_DATA];
This is my c++ struct (Use Multi-Byte Character Set) typedef struct hookCONFIG { int
Is this valid? public struct MyStruct { public int Foo { get; set; }
struct Drink { public string Name { get; private set; } public int Popularity
Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items
Assuming I have this struct definition in C#: public struct TimeSlotInfo { public int
From http://csharpindepth.com/Articles/Chapter8/PropertiesMatter.aspx using System; struct MutableStruct { public int Value { get; set; }
struct Group { Group(string _N, set <string> M_) {Name = N_; Member = M_}
I am trying to use the pt_regs struct to get and set registers such

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.