Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 3971400

@User 3971400
About
Posts
5
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How can a referece to integer constant change value in a function?
    U User 3971400

    Could someone pls explain the below question? Q1 : In line1 the second parameter is referece to integer constant. If so how is the value in 'x' changed to 4 Question:

    #include

    #include

    using namespace std;

    int mani(int (&arr)[10], const int& x)//Line1
    {
    for (int i = 0; i < 1; ++i)
    arr[i] = arr[i] + x;
    return x; //returns 4
    }

    int main(){
    int arr[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
    cout<

    C / C++ / MFC question

  • How is it possible to access private members of a class becoz the property of the field is made protected internal ?
    U User 3971400

    In the msdn page [^] it says "When a member of a class or struct is a property, field, method, event, or delegate, and that member either is a type or has a type as a parameter or return value, the accessibility of the member cannot be greater than the type. For example, you cannot have a public method M that returns a class C unless C is also public. Likewise, you cannot have a protected property of type A if A is declared as private. " But in this code

    class AccessSpecifier
    {
    // private field:
    private int wheels = 3;

       // protected internal property:
        protected internal int Wheels
        {
            get { return wheels; }
            set { wheels = value;  }
        }
    
    }
    class Derieved : AccessSpecifier
    {
        public void fun()
        {
            Wheels = 90; //accessing private mem of base class
        }
    }
    class main
    {
        public static void Main()
        {
            AccessSpecifier a = new AccessSpecifier();
            a.Wheels = 4;
            Console.WriteLine(a.Wheels); // gives 4 as output
            Derieved d = new Derieved();
            d.fun();
            Console.WriteLine(d.Wheels); //gives 90 as output
            d.Wheels = 99; //accessing private mem of a class in same assembly   :omg: 
            Console.WriteLine(d.Wheels);
            Console.ReadKey();
         
        }
    }
    

    How is this possible to access private members of a class jus becoz the property of the field is made protected internal ? And compiler is against the lines given in MSDN? Can u pls explain ?:confused:

    C# com tutorial question

  • Call to a constructor while executing (obj &lt; 3) . Kindly explain?
    U User 3971400

    Thanks :)

    C / C++ / MFC question

  • Call to a constructor while executing (obj &lt; 3) . Kindly explain?
    U User 3971400

    Thanks. :)

    C / C++ / MFC question

  • Call to a constructor while executing (obj &lt; 3) . Kindly explain?
    U User 3971400

    class CA{
    private:
    int m_Var;
    public:
    CA(int x=0): m_Var(x){cout<<"1";}
    bool operator < (const CA &obj2) { cout<<"2"; return (m_Var < obj2.m_Var) ? true : false;}
    };
    int main(void) {
    CA obj1=2;
    if(obj1 < 3){cout << "In If block" << endl;}
    }

    the output of this code is 112In If block .. i can understand the reason behind the first 1 and "2In If block" .. i dont understand when the second 1 is being called? as per my understanding when (obj1<3) executes it may call obj1.operator<(3) But constructor is being called but whats makes it to call? kindly explain why the second 1 is being displayed?

    C / C++ / MFC question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups