c++ ->
struct car {
int year
int vin;
}
struct car myCar;
p_myCar = &myCar;
myCar.year = 1995;
// '->' allows you to use the '.' with pointers
p_myCar->vin = 1234567;
c++ ->
struct car {
int year
int vin;
}
struct car myCar;
p_myCar = &myCar;
myCar.year = 1995;
// '->' allows you to use the '.' with pointers
p_myCar->vin = 1234567;
what is -> in c++
/**
* @author Charles Salvia (StackOverflow)
*
* -> is to access a member function or member variable of an object through
* a pointer, as opposed to a regular variable or reference.
*/
// For example: with a regular variable or reference, you use the . operator
// to access member functions or member variables.
std::string s = "abc";
std::cout << s.length() << std::endl;
//But if you're working with a pointer, you need to use the -> operator:
std::string* s = new std::string("abc");
std::cout << s->length() << std::endl;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us