Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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;
Comment

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;
Comment

>> c++

std::cout, << is used to write to standard output
std::cin,  >> is used to read from standard input.
Comment

PREVIOUS NEXT
Code Example
Cpp :: fabs in c++ example 
Cpp :: C++ operation 
Cpp :: Use command line arguments to create file c++ 
Cpp :: leetcode 36 c++ 
Cpp :: c++ to c converter online 
Cpp :: bash script add another user 
Cpp :: binary algebra cpp 
Cpp :: c++ call overriden method from constructor 
Cpp :: find a member variable in a vector of objects cpp 
Cpp :: how the theam are store in database 
Cpp :: asio broadcast permission 
Cpp :: time optimisation c++ 
Cpp :: left recursion program in c++ 
Cpp :: racing horses codechef solution c++ 
Cpp :: & before function arg in cpp 
Cpp :: 2160. Minimum Sum of Four Digit Number After Splitting Digits leetcode solution in c++ 
Cpp :: how to store array of string with spaces in c++ stl 
Cpp :: Smooth Poti values on Arduino 
Cpp :: check if an item is in a vector c++ 
Cpp :: c++ coding questions for interview 
Cpp :: opencv read gif c++ 
Cpp :: how to pass arrays by reference c++ 
Cpp :: palindrome no example 
Cpp :: vector to char array c++ 
Cpp :: c++ press any key 
Cpp :: cpp 
C :: pointer to a structure in c 
C :: Animated sprite from few images pygame 
C :: printf boo; 
C :: Write a C program to find reverse of an array 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =