klimi
Anonymous
I'm on cocaine
And I'm Heroine..😁😁😁
Anonymous
Why..?
klimi
Why..?
I just see
Anonymous
Hey..can anyone tell me . const int j=5; cout<<j; // will print 5 const_cast<int &>(j)=12; cout<<j; // still prints 5.. WHY...? 😳😳😳
klimi
Because j is 5
Anonymous
But I casted constantness of j
Anonymous
Now it has to be 12
klimi
Then it prints 12
klimi
^^
klimi
Problem solved
klimi
Just use some ... Imagination :33
klimi
I love rainbow
klimi
🌈
Dima
what the...
klimi
Anonymous
Who make you admin
klimi
Anonymous
U r not helping.. although..u r just speaking some shit.. instead of helping
klimi
Well
klimi
J is const
klimi
Then it's just 5
Anonymous
Yes
klimi
Anonymous
But
klimi
I don't know about that shit
Anonymous
The statement I provide
klimi
You're about to write
klimi
Yes
klimi
Whatever I don't know c++
Anonymous
Casting statement
Anonymous
I think u r also noob like me..
klimi
#include <iostream> using namespace std;    class student { private:     int roll; public:     // constructor     student(int r):roll(r) {}        // A const function that changes roll with the help of const_cast     void fun() const     {         ( const_cast <student*> (this) )->roll = 5;     }        int getRoll()  { return roll; } };    int main(void) {     student s(3);     cout << "Old roll number: " << s.getRoll() << endl;        s.fun();        cout << "New roll number: " << s.getRoll() << endl;        return 0; }
klimi
Not developer
Dima
This you just copied from geeksforgeeks.. I already checked it..and I don't understand... That's why I asked here
int a = const_cast<int &>(j); a = 12; std::cout << a; *burns in the hell*
Anonymous
int a = const_cast<int &>(j); a = 12; std::cout << a; *burns in the hell*
But ..I just want to change value of j without assigning it to another variable
Dima
is it your assignment to use const_cast?
klimi
You can't change it
klimi
It's constant
Anonymous
int a = const_cast<int &>(j); a = 12; std::cout << a; *burns in the hell*
I have better solution of this . std::cout<<*(&j)+7;
klimi
I would just do
Jakup
hello
klimi
STD::count<< j + 7;
Jakup
do you know group for begginers
Jakup
in c++
klimi
do you know group for begginers
This? ¯\_(ツ)_/¯
Dima
this group is for all sorts of conversations
Anonymous
xD
Dima
top kek
Anonymous
Lol, but that doesn't change j
Yes... j is stored in ROM.. So it's read-only variable..
Anonymous
If you just want to do that you can also write std::cout « j + 7;
klimi
top kek
Dima i don't get am I really idiot?
klimi
?
This group
Anonymous
Yes... j is stored in ROM.. So it's read-only variable..
Yes, but your "better" solution isn't the same what const_cast do
Anonymous
Okey.. Is it true..👇👇 const int i= rand();
Jakup
another
Jakup
group
klimi
I thought const just embedd the value while compiling
klimi
Rand is runtime
Anonymous
So it's wrong..?
klimi
I'm not a programmer
Anonymous
I'm not a programmer
Then how you know that compile time and run time parameters..?
Anonymous
Sometimes I'm that confused by beginner questions, cause I don't even can determine what they maybe mean... xD
Anonymous
Sometimes I'm that confused by beginner questions, cause I don't even can determine what they maybe mean... xD
I know..I'm begginer.. But instead of writing that much..you just can answer my question in one or two lines.. Isn't it..?
Anonymous
Well, I would, if I would understand what do you want from us
I just ask that..the statement I wrote..is it right..?