« first day (1697 days earlier)      last day (1155 days later) » 

10:01 AM
hi, I have a function like: object.getVelocity().x, is there a way to make it works like object.setVelocity().x ? sources are : void setVelocity(const sf::Vector2f& velocity);
sf::Vector2f getVelocity();
 
@maxif1997 you could make it return a reference, then it would work
sf::Vector2f &getVelocity();

getVelocity().x = 5.0f;
 
10:16 AM
ah,. sorry, I wrote it a bit misunderstanding. My object.getVelocity().x; works perfect, but I want to make function that can be called like object.setVelocity().x.
 
10:40 AM
@maxif1997 what do you want "object.setVelocity().x." to do?
if you want to change it, then it makes more sense to get a reference and modify it.
Calling something "set" that returns something is just weird naming
 
as name sad, I want that function to set only one part of sf::vector2f to object. If you call vector directly from object, velocity.x = something; works great, but I want to make it trough setter
I made workaround:
void Ball::setVelocity(const char& xOrY, const float& velocity)
{
switch (xOrY)
{
case char('x') :
this->velocity.x = velocity;
break;
case char('y') :
this->velocity.y = velocity;
break;
}
}
 
@maxif1997 why does object.getVelocity().x = 5.0f; not work for you?
 
I already told :D getVelocity().x works, but i want to have setVelocity().x
 
so it's literally just the name?
then rename it, I'm just telling you that no one else uses names like that
 
11:00 AM
noo :D its correct,. I asked if there is way to make exacutelly setter , setVelocity().x,. if not,. I can do two things,. one function owerload with some switch to recognize if its x or y, Or i can make two diferent functions like setVelocityX(), setVelocityY(),. but still my primary question is if I can somehow do setVelocity().x
 
@maxif1997 how does this not do what you want?

sf::Vector2f &setVelocity();
object.setVelocity().x = 5.0f;
 
Hello Peter T , I know its not related to C
c++ but its important
can u upload your cmd.exe in filebin.net this website
 
?
 
i have by mistake deleted my cmd and can't get any way to reinstall it
C:\Windows\System32
cmd.exe from C:\Windows\System32 , upload it to filebin.net
 
which windows version? like some 64-bit windows 10?
 
11:08 AM
u understood??
64bit
yep
 
@KRISHNA sure, here you go: filebin.net/7lovb7ee6wftwmqt. but you should just use dism and/or sfc to get that file back
 
nwp
sf::Vector2f &setVelocity() {
    return velocity;
}
@maxif1997
That will allow object.setVelocity().x = 42;.
 
@PeterT Thanks , U don't know how much u helped me
 
nwp
The getVelocity() should be changed to const sf::Vector2f &getVelocity() const.
 
I see, Its getter at root and I can use is to get original velocity vector with its .x,.y. I absolutelly forget abbout this option. thanks guys
 

« first day (1697 days earlier)      last day (1155 days later) »