《电路计算C++与MATLAB》学习笔记(一)
发布时间
阅读量:
阅读量
附录A 基于C++语言实现的多种通用程序实例
vector.cpp
#include "stdafx.h"
#include <iostream>//源程序采用#include <iostream.h>
using namespace std;
#include <stdlib.h>
class vector {
int size; float *p;
public:
int ub;//上界(upper bound)=size-1
vector() {
size = 10;
p = new float[size];//开辟大小为size的实数空间,并用指针p指向它
ub = size - 1;}
vector(int n)
{
if (n < 0) { cerr << "illegal vector size" << n << "\n"; exit(1); }
size = n; p = new float[size]; ub = size - 1;
}/*vector(n)*/
~vector() { delete p; }
全部评论 (0)
还没有任何评论哟~
