⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 一本语言类编程书籍
💻 CPP
字号:
// Exercise 11.3 Exercising SharedData - main.cpp
#include "shareddata.h"
#include <iostream>
using std::cout;
using std::endl;

int main() {
  int number = 99;
  long lNumber = 9999999L;
  double value = 1.7320508;
  float pi = 3.142f;
  SharedData shared = { 0.1 };  // Initially a double
  shared.show();

  // Now try all four pointers
  shared.piData = &number;      
  shared.type = pInt;
  shared.show();

  shared.plData = &lNumber;
  shared.type = pLong;
  shared.show();

  shared.pdData = &value;
  shared.type = pDouble;
  shared.show();

  shared.pfData = &pi;
  shared.type = pFloat;
  shared.show();

  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -