小编kd7*_*vdb的帖子

Infile不完整类型错误

我正在构建一个以这种格式获取输入文件的程序:

title author

title author

etc

and outputs to screen 

title (author)

title (author)

etc
Run Code Online (Sandbox Code Playgroud)

我目前遇到的问题是错误:

"ifstream infile的类型不完整,无法定义"

以下是该计划:

#include <iostream>              
#include <string>
#include <ifstream>
using namespace std; 

string bookTitle [14];
string bookAuthor [14];
int loadData (string pathname);         
void showall (int counter);

int main ()

{
int counter;  
string pathname;

cout<<"Input the name of the file to be accessed: ";
cin>>pathname;
loadData (pathname);
showall (counter);
}


int loadData (string pathname) // Loads data from infile into arrays
{
    ifstream infile; …
Run Code Online (Sandbox Code Playgroud)

c++ arrays file-io function

6
推荐指数
1
解决办法
2万
查看次数

使用嵌入式if和else if语句C++

继承我的代码我试图整理学校,在嵌入式if和else if语句中,当我尝试编译时它显示错误.

错误:期望在"else"之前的primary-expression';' 在别的之前

这两个都出现在每一行.

// This is a program to Calculate the volume of the sphere using the radius (a03.cpp)
// Written by: Jimmy Scott
// Date: 2/1/12
// Sources: Stackoverflow.com (else and if statements)


#include <iomanip>
#include <iostream>              
#include <string>

using namespace std;                

int main ()

{
    char vehicle;   
    float total;
    char over20;
    char old;
    int adults;
    int oldpass;
    char height;
    int youngpass;
    int bicycles;
    float length;

    cout<<"Fare Calculator by Jimmy Scott";
    cout<<"\n\n\n Are You Bringing a vehicle …
Run Code Online (Sandbox Code Playgroud)

c++ new-operator

1
推荐指数
1
解决办法
297
查看次数

标签 统计

c++ ×2

arrays ×1

file-io ×1

function ×1

new-operator ×1