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

程序运行时总是出现这个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 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能