我在创建一个返回我自己的struct的函数时遇到了麻烦.
标题:
#ifndef FOOD_H
#define FOOD_H
#include <string>
class Food
{
public:
Food();
~Food();
public:
struct Fruit {
std::string name;
};
struct Person {
Fruit favorite;
Fruit setFavorite(Fruit newFav);
};
public:
Fruit apple;
Fruit banana;
Person Fred;
};
#endif
Run Code Online (Sandbox Code Playgroud)
CPP:
#include "Food.h"
Food::Food()
{
}
Food::~Food()
{
}
Fruit Food::Person::setFavorite(Fruit newFav)
{
return newFav;
}
Run Code Online (Sandbox Code Playgroud)
主要:
#include "Food.h"
#include <iostream>
int main() {
Food fd;
fd.Fred.favorite = fd.Fred.setFavorite(fd.apple);
std::cout << fd.Fred.favorite.name;
system("pause");
}
Run Code Online (Sandbox Code Playgroud)
我的错误是:
E0020标识符"Fruit"未定义Food.cpp 11
E0147声明与"Food :: Fruit Food …
我是C++,directX和Windows编程的新手.
这是我引用的头文件,以及我正在使用的命名空间:
#include "pch.h"
#include <Windows.h>
#include <iostream>
#include "Common/DirectXHelper.h"
using namespace Windows;
using namespace Microsoft::WRL;
using namespace Windows::UI::Core;
using namespace std;
Run Code Online (Sandbox Code Playgroud)
以下是导致错误的行:
return (GetAsyncKeyState(key) & 0x8000 != 0);
Run Code Online (Sandbox Code Playgroud)
我不知道我是否拼写错误或是否是编译器问题,我已经到处查看并且没有找到解决方案.
我也尝试过使用GetCursorPos方法,但它没有用.
提前致谢.
编辑:错误消息是:
错误C3861:"GetAsyncKeyState":找不到标识符
key是一个int,它具有我正在测试的密钥的密钥代码
我正在使用Visual Studio 2017进行C++开发,并且无法通过IDE设置一些内容,例如stackcommit.
我真正想看到的是IDE如何调用编译器/链接器.
我在"查看"菜单下找不到任何此类选项,并想知道是否有人找到了这样做的方法吗?
我正在Visual Studio 2017中的ASP.NET Core项目上工作,该项目设置为在IIS Express中运行。该项目是由其他同事启动的,我只是克隆了存储库,但是在我的机器上,所有API端点都返回404 Not Found。我尝试从Startup类中删除所有配置,仅保留Mvc功能,但这无济于事。
#include<cstdlib> //Required for compatibility
#include<cmath> //Required for pow
#include<fstream> //Required for data files
#include<iostream> //Required for cout and cin
#include<iomanip> //Required for setw
using namespace std;
int choice, loops, count;
double initTime, timeIncrement, finalTime, time, A1, B1, C1, D1, E1,
altitude, A2, B2, C2, D2, E2, velocity; //This is line 20 as the error notes
//Declare variables
ifstream inFile;
ofstream outFile;
void menuFunction() {
//Main menu function where user selects which option they would like to proceed with, not relevant …Run Code Online (Sandbox Code Playgroud) 我很高兴看到std::experimental::filesystemVisual Studio 2017中增加了对它的支持,但刚才遇到了Unicode问题。我有点盲目地假设我可以在任何地方使用UTF-8字符串,但是失败了- 将a 构造为std::experimental::filesystem::path从a char*到UTF-8编码的字符串时,不会发生任何转换(即使标头在内部使用_To_wide和_To_byte起作用。我也写了一个简单的测试示例:
#include <string>
#include <experimental\filesystem>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
static inline std::string FromUtf16(const wchar_t* pUtf16String)
{
int nUtf16StringLength = static_cast<int>(wcslen(pUtf16String));
int nUtf8StringLength = ::WideCharToMultiByte(CP_UTF8, 0, pUtf16String, nUtf16StringLength, NULL, 0, NULL, NULL);
std::string sUtf8String(nUtf8StringLength, '\0');
nUtf8StringLength = ::WideCharToMultiByte(CP_UTF8, 0, pUtf16String, nUtf16StringLength, const_cast<char *>(sUtf8String.c_str()), nUtf8StringLength, NULL, NULL);
return sUtf8String;
}
static inline std::string FromUtf16(const std::wstring& sUtf16String)
{
return FromUtf16(sUtf16String.c_str());
}
static inline std::wstring ToUtf16(const char* pUtf8String)
{
int …Run Code Online (Sandbox Code Playgroud) 对事件对象执行空检查时,Visual Studio会将代码颜色更改为浅灰色。如果我没记错的话,通常意味着这行是不必要的。显然,在我的情况下不是这样(或者是?)。请参阅下面的示例:
public event PropertyChangedEventHandler PropertyChanged;
string test;
protected void OnPropertyChanged (string propertyName)
{
if (PropertyChanged != null) { //This line is grey
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
} //This line is grey
if (test != null) {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Run Code Online (Sandbox Code Playgroud)
我已将我的项目从旧的Visual Studio SPA Angular模板转换为最新的模板.我还将项目从Angular 5转换为Angular 6,从webpack转换为angular-cli.后端正在运行.Net Core 2.1.1.
它在dev中都很好用但是在部署到IIS时我遇到了500错误.最新的主机软件包安装在IIS中并运行正常.我可以部署旧版本的应用程序,它运行良好但新的拒绝合作.
我也没有看到日志文件试图追踪它.
有什么想法吗?
这是我的angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"ClientApp": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/ClientApp",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"node_modules/font-awesome/css/font-awesome.min.css",
"node_modules/primeng/resources/primeng.min.css",
"node_modules/primeicons/primeicons.css",
"node_modules/videogular2/fonts/videogular.css",
"src/assets/theme/theme-blue.scss",
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [ …Run Code Online (Sandbox Code Playgroud) 我已将AfterBuild目标添加到Visual Studio项目,这是包含多个Visual Studio项目的解决方案的一部分。
解决方案设置示例
例子.sln
ExampleProj.csproj
ExampleProj.Test.csproj
目标示例:
<Target Name="PostBuildScript" AfterTargets="AfterBuild" Condition="'$(Configuration)' == 'Release'">
<PropertyGroup>
<BuildCommand>"SomeApplication.exe")</BuildCommand>
</PropertyGroup>
<Exec Command="$(BuildCommand)" ConsoleToMSBuild="true" LogStandardErrorAsError="true" WorkingDirectory="$(ProjectDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我希望此目标仅在解决方案中的所有Visual Studio项目都已建立之后才能执行。
有没有办法实现这一目标。
注意:dotnet build在Visual Studio中使用和生成命令时,我的行为必须相同。
我安装了Visual Studio 2017.在安装程序菜单中,我安装了Xamarin和Visual C#.但是,当我创建一个新项目时,转到工具>选项> Xamarin,我看到android-ndk文本框是空的而其他文件框不是.
我在这条路径上安装了Visual Studio:D:\ Program Files\Visual Studio.但我不知道是否会将Xamarin安装到D:\
我的问题是android-ndk在哪里?
谢谢
android android-ndk xamarin.android xamarin visual-studio-2017