julywin 2014-11-01 12:47 采纳率: 0%
浏览 26873

程序运行时总是出现这个Process terminated with status -1073741510,求大神来帮帮忙

safearray.h文件
#ifndef SAFEARRAY_H
#define SAFEARRAY_H

#include

template
class safearray {

private:
T* storage;
int capacity;

public:
safearray() : storage(NULL), capacity(0) {} // default constructor
safearray(const safearray& c){
capacity=c.capacity;
storage=new T;
storage=(c.storage);
};
safearray(int); // single param constructor
~safearray(void); // destructor
T& operator throw(out_of_range);
};
template
safearray::safearray(int i):capacity(i),storage(new T[i])
{}

template
safearray::~safearray()
{
delete [] storage;
}

template
T& safearray::operator throw(out_of_range)
{
if(i(capacity-1)){
out_of_range e("The index is out of range of array");
throw e;
}else
return storage[i];
}

#endif

course头文件

#ifndef COURSE_H
#define COURSE_H
#include "safearray.h"

const int MAX_LINES = 10;

class course {

public:
string name;
string title;
//string description[MAX_LINES];
safearray description;

course()
{
    name="";
    title="";
    description=safearray<string>(MAX_LINES);
}
course(string name, string title)
{
    name=name;
    title=title;
    description=safearray<string>(MAX_LINES);
}
friend ostream& operator<<(ostream&,const course&);
friend istream& operator>>(istream&, course&);

};

ostream& operator<<(ostream& out, course& c) {

out << c.name << ": " << c.title << "\n";

int index = 0;
while (c.description[index] != "") {
    out << c.description[index++] << "\n";
}

return out;

}

istream& operator>>(istream& in, course& c) {

getline(in, c.name);
getline(in, c.title);

string line;
getline(in, line);
int number = 0;
while (line != "") {
    c.description[number++] = line;
    getline(in, line);
}
return in;

}

#endif

main.cpp

// For Visual C++ users:
// Visual C++ does not implement checked exceptions, and the compiler will
// show warning messages when functions throws exceptions. The following
// warning pragma ignore those compiler messages.
//
// GCC users can remove this #pragma warning.
#pragma warning(disable: 4290)

#include
#include
#include
#include

using namespace std;

#include "course.h"
#include "safearray.h"

void init_courses(safearray&);
void display_menu(safearray);

const int NUM_COURSES = 10;
const int QUIT = 99;

int main(int argc, char* argv[]) {

safearray<course> courses(NUM_COURSES);
init_courses(courses);

int choice = 0;
while (choice != QUIT) {

    display_menu(courses);
    cout << "Enter number of course to see more information on\n";
    cin >> choice;
    cout << "\n";

    if (choice >= 1 && choice <= NUM_COURSES) {
        cout << courses[choice - 1] << "\n\n";
    }
}

return EXIT_SUCCESS;

}

void display_menu(safearray courses) {
for (int i = 1; i <= NUM_COURSES; i++) {
cout << i << ". " << courses[i - 1].name << "\n";
}
cout << "99. Quit\n";
}

void init_courses(safearray& courses) {
ifstream inf("courses.txt");
if (! inf) {
cerr << "Could not open courses.txt" << endl;
exit(EXIT_FAILURE);
}
for (int i = 0; i < NUM_COURSES; i++) {
inf >> courses[i];
}

inf.close();

}

求大神来帮帮忙,

  • 写回答

3条回答 默认 最新

  • caged_bird 2015-04-05 08:56
    关注

    又是Code::Blocks,老显示Process terminated with status -1073741510,今天查了一下。

    -1073741510就是0xC000013A,也就是STATUS_CONTROL_C_EXIT。

    应该是运行中按CTRL+C终止程序运行时返回这个值。

    However this exit code simply means that the CMD Prompt Windows was closed during execution of the script.

    表示命令窗口在程序执行过程中被关闭。

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题