系统找不到 Visual Studio 2012 上指定的文件

问题描述 投票:0回答:2

我不知道我做错了什么,一直说找不到指定的文件。真的想不通这个问题

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

int main ()
{
    string name;
    double courseNumber;
    double hoursWorked;
    const double payPerHour = 8.25;


    cout << "What is your name and what is your course number? " << endl;
    cin >> "Name " >> name >> " CourseNumber " >> courseNumber;
    cout << name << "Welcome to the C++ course numbered " << 
    courseNumber << endl;

    cout << "How many hours did you work this pay period? " << endl;
    cin >> hoursWorked;
    cout << name << 
    " You worked " << hoursWorked << " hours at " << 
    payPerHour << " per hour. " << endl;

    system("pause");
    return 0;
}
c++ visual-studio-2012
2个回答
1
投票
 cin >> "Name " >> name >> " CourseNumber " >> courseNumber;

从 cin 中删除这些字符串,它应该可以正常工作。


0
投票

请将这2段代码添加到文件中(这里我在创建项目时将这2个初始文件称为MainProject)MainProject.cpp:

#include "MainForm.h"

using namespace System;
using namespace System::Windows::Forms;

[STAThread]
int main(array<String^>^ args) {
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    FirstCppProject::MainForm form;
    Application::Run(% form);
    return 0;
}

和 MainProject.h(GUI 代码文件)

#pragma once

namespace FirstCppProject {
    public ref class MainForm : public System::Windows::Forms::Form {
    public:
        MainForm() {
            InitializeComponent();
        }

    private:
        System::Void InitializeComponent() {
            this->SuspendLayout();
            // Initialize other components here
            this->ResumeLayout(false);
        }
    };
}

然后保存并再次运行程序(构建 -> 构建解决方案)

© www.soinside.com 2019 - 2024. All rights reserved.