总结学习

来源:互联网 发布:网络语言tnt是什么意思 编辑:程序博客网 时间:2024/05/22 20:07

这 段 时 间 主 要 在 做 C++ 和 QT 的 学 习,把 C++ 中 的 类 和 继 承 看 完 了,在 学 习 QT 中 理 解 到 QT 里 面很 大 一 部 分 是 C++ 的 相 关 东 西,需 要 有 很 好 的 C++ 的 功 底 和 基 础 知 识。

目 前 在 C++ 里 的 学 习 还 有 很 多 的 不 足 和 难 点,还 应 加 大 对 C++ 的 学 习 力 度,在  C++ 的 基 础 上 将QT 的 一 些 相 关 部 分 进 行 整 合 理 解 和 基 本 的 相 关 操 作 和 训 练。

C++继承了C语言的预处理、指针、标准库。添加了模板、类等高层次的封装。

#include<iostream>
#include"stock00.h"


void Stock :: acquire(const std :: string & co, long n, double pr)
{
  company = co;
  if (n < 0)
  {
 std :: cout << "Number of shares can't ba negative;"
         << company << "shares set to 0.\n";
 shares = 0;
  }
  else
  shares = n;
  share_val = pr;
  set_tot();
}


void Stock :: buy(long num, double price)
{
if(num < 0)
{
std :: cout << "Number of shares purchased can't be negative."
                << "Transaction is aboretd.\n";

else
{
shares += num;
share_val = price;
set_tot();
}
}


void Stock :: sell(long num, double price)
{
using std :: cout;
if(num < 0)
{
  cout << "Number of shares purchased can't be negative."
<< "Transaction is aboretd.\n";
}
else if(num > shares)
{
cout << "You can't sell more than you have!"
<<"Transaction is aboretd.\n";
}
else
{
shares -= num;
share_val = price;
set_tot();


}
}


void Stock :: update(double price)
{


share_val = price;
set_tot();
}


void Stock :: show()
{
std :: cout << "Company:" << company
       <<" Shares:"  << shares << '\n'
<<"Share Price : $" << share_val
<<" Total Worth: $" << total_val << '\n';


}

#include<iostream>
#include"stock00.h"
int main()
{
using namespace std;
Stock fluffy_the_cat;
fluffy_the_cat.acquire("NanoSmart", 20, 12.50);
fluffy_the_cat.show();
fluffy_the_cat.buy(15, 18.125);
fluffy_the_cat.show();
fluffy_the_cat.sell(400, 20.00);
fluffy_the_cat.show();
fluffy_the_cat.buy(300000, 40.125);
fluffy_the_cat.show();
fluffy_the_cat.sell(300000, 0.125);
fluffy_the_cat.show();


cin.get();
cin.get();



}




#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
}
Dialog::~Dialog()
{
    delete ui;
}


#include<drawer.h>
#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Drawer w;
    w.show();
    return a.exec();
}
#include<drawer.h>
#include<QGroupBox>
#include<QVBoxLayout>
Drawer::Drawer(QWidget  *parent,Qt::WindowFlags f)
    :QToolBox(parent,f)


原创粉丝点击