SHP
Just used it at my beginning of c programming for bout 45 mins, then i switched to codeblocks and 1 year later vscode
Pavel
#
Solve my problem
Aakash
Who are "they"?
I am just begineer that's why I am asking
Anonymous
Will Rust Replace C++ in Future ?
SHP
nope i think
Terrorist
What time is it now?
Anonymous
Does c++ have special advantages over rust?
Nomid Íkorni-Sciurus
Does c++ have special advantages over rust?
It depends on what kind of advantages are you interested in
Pavel
Does c++ have special advantages over rust?
More popular; more ways to inflict pain to the future self, but more fun for the present self; has no alternatives in software like videogames
Ighor
anyone need a bot that automatically remove that 💩?
Ighor
nice job but it is annoying to see that spam stays time to time here
Dima
nothing personal, but who knows what this bot would do
Ighor
nothing personal, but who knows what this bot would do
bots don't have access to remove messages older than 24h, and my bot don't need rights to ban, so it can't harm. I can explain how it works, but you won't be able to use its code, since it is running in custom engine
Egro
void swap(int& x, int& y); int main() { using namespace std; int a = 45, b = 35; cout<<"Before Swap\n": cout<<"a = "<<a<<" b = "«<b<<"\n": swap(a,b); cout<<"After swap with pass by reference\n"; cout<<"a = "<<a<<" b = "<< b <<"'\n"; void swap(int& x, int& y) { int temp: temp = x; x = y; y = x; }
Egro
this code will not run... help me find out why
Jonathan
y = temp
Anonymous
Hello, can anyone help me to eliminate the Imaginary numbers in this code
Egro
y = temp
thank you
Egro
y = temp
damnn, silly me. its was like a big "duh" once i saw it too. mannn, super thank you.
Egro
Use std::swap
too advance for me
UnO1
can someone help me with this ... "write a program that enters a number and determine if the number is prime or composite using ELSE IF ONLY, without using loops"
UnO1
C++
Egro
can someone help me with this ... "write a program that enters a number and determine if the number is prime or composite using ELSE IF ONLY, without using loops"
master if & else, do many examples, until you can do them in your sleep pseudocode(in english) if input equal prime or composite, print yes, else , print , no.
Mr
?
Rule #2
Without nan as an element of number, scalar operator on number cannot be closed, you dont want to let cpp throw an exception when calculate 0/0.
Does c++ have special advantages over rust?
So does rust has special advantage over cpp? Beside that lifetime feature
Anonymous
Rust is strong too
Anonymous
So does rust has special advantage over cpp? Beside that lifetime feature
And something else Null is object in JavaScript 😊
Anshul
class A { public: A() { } private: int c; B obj; //Line 1 //B obj(c); // Line 2 }; class B { public: B(int t){ k = t; } private: int k; }; Here when i am trying to create an object of class B in class A i get error in trying it both way i.e. Line 1 and Line 2. as B doesn't have any default constructor i would need to call the parametrised constructor by passing an int. But I am getting error "B doesn't name a type"
Anshul
what is the right way to do it
SHP
forwarding declaration may help
SHP
it's because by the time B is used in A, You have no idea what B is, so put a single declaration of class B; before class A will solve this, maybe
SHP
@Pareekc1
SHP
ah, just noticed you also didnot construct B in a right way, A's default ctor cannot correctly default construct B
Anshul
with forward declaration when i do this , B obj(c); i get this error error: ‘c’ is not a type
SHP
it's because it identified obj of a function taking c type parameter, returning B type, which we often call most vexing parse
SHP
and you should construct B before function body after parameter list of ctor, not where it's declared
SHP
Let me give an example here: struct A { ... }; A x; // default construct A y(); // declare y as a function of no parameters and returning A.
SHP
so any y.A_function() / y.A_member will trigger compilation errors
Sen Sovisal
What is "include<stdio.h>" mean? please give the answers.
SHP
in your example, you may change A's ctor as: A() : c{0}, obj{c} {} A(int x) : c{x}, obj{c} {} or a one-liner: A(int x = 0) : c{x}, obj{c} {}
Anshul
What is "include<stdio.h>" mean? please give the answers.
stdio.h is a header file which contains declaration of standard functions used in C language
Anshul
also with obj why are we using two {} {} instead of just obj{c}
SHP
I'd prefer brace-initialization when both are ok, but there're differences when you have a ctor passing initializer_list, like std::vector<int> v{1, 2} and std::vector<int> v(1, 2)
SHP
also with obj why are we using two {} {} instead of just obj{c}
the later one is the compact format of function body of constructor
SHP
I assume a possible way is to make the calculation a private function, and then passing to c{func()}, rather than in ctor body
Anshul
Okay
Anshul
class A { public: A() : obj{fun()} { } private: int c; B obj; int fun(){ if(condition) { c = 0;} else {c = 1;} } };
Shadow
Rule #2
This program was asked by my lecturer.. I want full program..
Anshul
field ‘obj’ has incomplete type ‘B’
SHP
and fun() need to return c, I think
SHP
field ‘obj’ has incomplete type ‘B’
same question, you need to add class B; before class A { ... }
SHP
class B; class A { .... }; class B { .... };
Anshul
and fun() need to return c, I think
oh yea, i don't know why i am making silly mistakes
SHP
most simple fix would be move B before A, lol
SHP
Ah, I made mistakes here, plz ignore it
SHP
forwarding declaration does not work fine here, a big change is needed maybe
SHP
class B { public: B(int); private: int k; }; class A { public: A() : obj{fun()} {} int c; B obj; int fun() { return c = 1; } }; B::B(int t) : k{t} {}
Aquatica
This program was asked by my lecturer.. I want full program..
Don't go to school if you're not willing to learn nor put an effort