// pointers to structures
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
struct movies_t {
string title;
int year;
};
int main ()
{
string mystr;
movies_t amovie;
movies_t * pmovie;
pmovie = &amovie;
cout << "Enter title: ";
getline (cin, amovie.title); //using object
cout << "Enter year: ";
getline (cin, mystr);
(stringstream) mystr >> pmovie->year;
cout << "\nYou have entered:\n";
cout << pmovie->title; //using object-pointer
cout << " (" << pmovie->year << ")\n";
return 0;
}
structure-object structure-object-pointer
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
ES6的Object.fromEntries()和Object.hasOwn()
Object.fromEntries()方法是Object.entries()的逆操作,用于将一个键值对数组转为对象。
键值对 Object.hasOwn() Object.fromEntries -
Data structure
数据结构的wiki。
职场 数据结构 休闲