PDA

View Full Version : مبتدی: مشکل در درک کردن یک خط برنامه



raminlich
یک شنبه 11 خرداد 1393, 23:27 عصر
// example about structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

struct movies_t {
string title;
int year;
} mine, yours;

void printmovie (movies_t movie);

int main ()
{
string mystr;

mine.title = "2001 A Space Odyssey";
mine.year = 1968;

cout << "Enter title: ";
getline (cin,yours.title);
cout << "Enter year: ";
getline (cin,mystr);
stringstream(mystr) >> yours.year; //این یکی

cout << "My favorite movie is:\n ";
printmovie (mine);
cout << "And yours is:\n ";
printmovie (yours);
return 0;
}

void printmovie (movies_t movie)
{
cout << movie.title;
cout << " (" << movie.year << ")\n";
}
سلام
من این خط رو نمی فهمم چرا اینجوری شده؟

emadrezvani
دوشنبه 12 خرداد 1393, 10:40 صبح
http://stackoverflow.com/questions/20594520/what-exactly-does-stringstream-do