Anonymous
can i message you?
no just reply here
Sameer
Ok....
Sameer
I actually want to say that. We are making the enum [enumerator] in which we are giving some data like we assigned variable to the data .
Sameer
So why we need enum if we can directly assigned the data to variable
piggyho
no just reply here
user @sarika_14 PM'd me and just said solve this. not even please 😀
Sameer
Is that related to memory allocation .
Sameer
user @sarika_14 PM'd me and just said solve this. not even please 😀
Bro i think his personal opinion to allow me Or not.
Anonymous
user @sarika_14 PM'd me and just said solve this. not even please 😀
i get them multiple times a day. i just answer if they are 1-2 line answers. otherwise point them to group. and lmao i just banned and reported @sarika_14 because i thought they were a bot.
Sameer
a shame people are like that
Bro can you please forgot ,that just every boy do bro
Anonymous
So why we need enum if we can directly assigned the data to variable
we don't "need" enums. but they are nice to have. https://stackoverflow.com/questions/4709175/what-are-enums-and-why-are-they-useful
Sameer
a shame people are like that
Thank you bro helping me through out.
Anonymous
np
Anonymous
so this one should be all fine right? Sorry to make you look through that
i was about to "invent" a transforming iterator class for you. then i found out that boost already has a transform_iterator
数学の恋人
数学の恋人
Amit
Class A{ Private: Int a ; Public: A(){ a=0;} friend class B; }; Class B { Private: Int b; Public: Void show(A& x) {. Cout<<x.a<<endl; } }; Int main(){ A a; B b; b.show(a) ; }
Amit
In the program above why I need to pass reference of A class object to access int var a of class A
Amit
Let's not focus on syntactical mistakes here
Amit
My question is......instead of passing reference to object A
Amit
Why can't I directly access var a(class A)
Amit
From class B , as B is already a friend class
Amit
Void show(){ Cout << A::a <<endl; }
Anonymous
Void show(){ Cout << A::a <<endl; }
A::a is not a static member variable
Amit
I want to access var int a (of class A) directly from class B.... without passing A obj reference
Anonymous
Void show(){ Cout << A::a <<endl; }
one sentence hint for you - "an object is an instance of a class"
Amit
Yeah I understand that....but how that hind is related here
Amit
Oh okkie
Amit
But as class B is friend to class A
Amit
Doesn't that gives class B access to
Amit
All members of class A
Amit
So that means....even class B object can access int var a
Amit
Does it like inheritance only
Amit
Like now class B contains all members of class A
Anonymous
Does it like inheritance only
???? no. inherited classes cannot access the private members of a base class
Amit
When I assign class B as friend to class A
Amit
???? no. inherited classes cannot access the private members of a base class
Yeah that's the only difference in inheritance and friend class
Amit
?
Anonymous
Amit
What's the difference I want to know
Anonymous
What's the difference I want to know
what's the difference between a mango and mars?
Amit
Other than that friend class can even access private and protected members
Anonymous
Other than that friend class can even access private and protected members
If you need that kind of access your code is f***ed in the first place
Amit
I know friend Concept shouldn't be used frequently....buts let's just say we only have two classes
Anonymous
And you should rethink your code
Amit
In that case.....only difference will be a friend class would have acess to private data members while inheritance doesn't allow that
Anonymous
Other than that friend class can even access private and protected members
Class A { friend class B; ^^^^^^^ just a declaration that B can access A's private and protected members. This doesn't add an object of class A to class B. private: int a ; public: A() : a(0) {} };
Amit
What other differences I'm missing here
Anonymous
What other differences I'm missing here
they are two entirely different ideas. there is no comparison between a mango and mars
Pavel
Do we have an ability to pass copy of an object instead of reference without creating a named variable? Like opposite of std::ref like in this case append function is not safe to call with itself (it modifies it's own data during the call and reading the argument data at the same time). MyType value; ... value.append(value); what we can do is call it like this MyType copy = value; value.append(copy); but we need a named variable for that. can we avoid using the named variable?
Pavel
I'm probably missing something very obvious here...
Amit
Class A{ Private: Int a ; Public: A(){ a=0;} friend class B; }; Class B { Private: Int b; Public: Void show(A& x) {. Cout<<x.a<<endl; } }; Int main(){ A a; B b; b.show(a) ; }
In case I want to acess int var a (of class A) from class B's object in main....it's throwing error Int main(){ A a1; B b; Cout<< b.a << endl; Return 0; } What's wrong I'm doing here... anybody??
Pavel
I can't modify append in this case, also it won't solve the issue because I need to append the class to itself so I need a copy.
Pavel
Ah I missed the part with a copy creation but sadly anyway I can't modify it
Anonymous
Write a program that gets a natural number N (N ≥ 3) at the input, then a sequence of whole N elements. As a result, the program must display the 3 largest elements of the sequence. The elements should be displayed from small to large and separated by spaces. It is forbidden to use mass.
Anonymous
#include <iostream> int main() { int N; std::cin >> N; if ( N >= 3 ){ for ( i = N; i >= 0; i--){ std::cout << i << " "; } } }
Anonymous
somebody help find the error
Anonymous
for (i=N; i>= 0;i—)I think it is here
Anonymous
somebody help?
Artöm
i is not defined
Pavel
somebody help find the error
You're just printing all the elements, you're not finding the biggest ones
Anonymous
ok
Anonymous
you can help find
@unchanted
Use if case inside the for loop
Anonymous
tell me how to find?
Pavel
ok
Also i should start from zero, not from N
Anonymous
for ( i = 0; i >= N; i--){