Modern College
hii
Modern College
#include<iostream> using namespace std; int main() { int x,y; cout<<"Enter your numbers:"; cin>>x,y; { if(x>y) cout<<"x is greter number"; cout<<"y is smaller number"; else cout<<"y is greater number"; cout<<"x is smaller number"; } return 0; }
Modern College
can anyone tell me what's wrong in this
Modern College
Expect spelling mistake
Modern College
But it the compiler is saying that you need a ; before cout
Modern College
And if is needed before else
Apk
And if is needed before else
you need a paranthesis after if for multiple statements inside if
Modern College
im actukky new in it pls.. help
Apk
means
if (condition) { your code }
Modern College
if (condition) { your code }
I didn't get that
Apk
I didn't get that
Read about if syntax
Anonymous
No there are two variables in the declaration part
Anonymous
Oh yes... sorry
Anonymous
And its a tricky question keep it up
Modern College
Its have a syntax error cin>>x>>y; and this is the part
I get that and also corrected that but still there is error
Modern College
The cin just accept one variable
No in my compiler it cheats 2 bit still that error
Modern College
It's say there is no if before else statement
Anonymous
It's say there is no if before else statement
#include<iostream> using namespace std; int main() { int x,y; cout<<"Enter your numbers:"; cin>>x,y; if(x>y){ cout<<"x is greter number"; cout<<"y is smaller number"; } else { cout<<"y is greater number"; cout<<"x is smaller number"; } return 0; }
Anonymous
No in my compiler it cheats 2 bit still that error
Means it accepts only one variable at a time
Modern College
Modern College
If you use cin>>a>>b>>c
Anonymous
Guys what is the use of STL(C++) Container in Data structures ?
Anonymous
Guys what is the use of STL(C++) Container in Data structures ?
The STL containers ARE the data structures.
Anonymous
What is the use assoctive container?
Anonymous
What is the use assoctive container?
To store key value pairs or in the case of sets to store keys alone
Anonymous
Which container used to create tree?
Anonymous
Anonymous
Go read a good book
Can you share those books?
Anonymous
Can you share those books?
Algorithms - 4th edition by Robert Sedgewick.
Anonymous
Okay thank you ma'am
Anonymous
add |= (1ll <<j) Came across this What does this "|=" mean?
Anonymous
operator after add
Anonymous
oh lol yes sorry my bad it ORs with the value present in add
Anonymous
Valsa, ?
Anonymous
data should not be immutable if it is inside of a [&] capture right?
Anonymous
so it is immutable inside of a [&] capture?
Anonymous
so it is immutable inside of a [&] capture?
If it is captured by reference it is mutable. Only by value captures are immutable. You have to use the mutable keyword to make them mutable inside the lambda
Anonymous
hmmm ok
Anonymous
well somehow my variables are immutable ;-;
Anonymous
it is a bit complex
Anonymous
it is a bit complex
Then I guess you must have made a mistake somewhere. Are you getting compiler errors when you try to mutate the reference inside the lambda body?
Anonymous
objectBase = std::move(cube); timeEngine.physicsCallback = [&](const TimeEngine & timeEngine) { auto obj = objectBase.get<ObjectBase*>(); obj->physics(timeEngine); };
Anonymous
void TimeEngine::startPhysicsThread() { if (running.load()) return; running.store(true); physicsThread = std::thread([&] { TimeEngine physicsTimeEngine; physicsTimeEngine.resetTimer(); while(running.load()) { if (physicsTimeStep == 0.0) { physicsCallback(physicsTimeEngine); continue; } } }); }
Anonymous
void Cube::physics (const TimeEngine & timeEngine) { using namespace Diligent; y += 70.0 * timeEngine.delta; auto radY = degreesToRadians(y); CubeModelTransform = float4x4::RotationY(radY) * float4x4::RotationX(-PI_F * 0.1f); }
Anonymous
that is my code
Anonymous
that is my code
It is a bit difficult to work with that. Usually in forums like these what helps is an MVCE.
Anonymous
yea
Anonymous
how about this instead?
Anonymous
as physicsTimeStep is 0 anyway
Anonymous
as physicsTimeStep is 0 anyway
Where do you get the error? Is it at the get call inside the lambda body. The name get doesnt suggest it is a mutating call btw. Is it a const method?
Anonymous
however, oddly if i change the timestep to 0.25/60.0 then my object becomes mutable
Anonymous
but i am not sure why it becomes immutable when timestep is 0
Anonymous
#include <iostream> using namespace std; int main(){ int a = 10; auto func = [&]{++a;}; func(); cout << a << endl; } Reference captures are mutable as this example shows. I am not sure what is wrong with your code with just the data ou have given. So guess you will have to debug it yourself.
Anonymous
🙁
Anonymous
Hi! I am a beginner. I wanted to ask where you learnt c++ from? How to practice?
From books just like everyone else and also at work. If you want to learn about C++ follow the books mentioned in the pinned thread (the stackoverflow link) and thereafter it is just practice that makes you better....you can practice by picking up some easy C++ code bases on github like log4cpp and so on and make changes....
Anonymous
/get cbook
M
Any one knows basics of OOP I have a project and I make the classes and everything and It was working so good till I tried to separate a cpp class into . h and . Cpp files
Anonymous
Here is the c++ books list https://stackoverflow.com/q/388242/3493289
M
It keeps giving me undefined reference to (student::student())
Anonymous
M
https://pastebin.com/BmzsdsZA
Anonymous
I see the constructor is defined in the cpp file. Not sure why the linker is complaining. I am not near a system right now. I will check it when I am nea one. Should be a simple issue.