0
저는 C++을 처음 사용하므로 열거 형 값 배열을 포함하고 Microsoft Visual Studio에서 구문 오류가 발생합니다. 왜 이것이 도움이 될지 모르겠다. 오류 번호가 C2061이며이 "구문 오류 상태 :.매개 변수로 열거 형 배열 C++
헤더 파일
#include "verbose_binary.h"
#include "stdafx.h"
#include <bitset>
#include <string>
#include <iostream>
void convert(std::bitset<5> bs, VerboseBinary aVB[6]) {
VerboseBinary VBArray[6] = {
VerboseBinary:: One,
VerboseBinary:: Two,
VerboseBinary:: Four,
VerboseBinary:: Eight,
VerboseBinary:: Sixteen,
VerboseBinary:: Null
};
for (int i = 0; i < 5; i++) {
if (bs.test(i)) {
aVB[i] = VBArray[i];
}
else {
aVB[i] = VerboseBinary::Null;
}
}
aVB[5] = VerboseBinary::Null;
}
홈페이지
verbose_binary.cpp#pragma once
#include <bitset>
enum class VerboseBinary : int {
One,
Two,
Four,
Eight,
Sixteen,
Null,
};
void convert(std::bitset<5> bs, VerboseBinary aVB[6]);
verbose_binary.h : 식별자 'VerboseBinary을'여기에 코드입니다
#include "stdafx.h"
#include <iostream>
#include <iostream>
#include <bitset>
#include "verbose_binary.h"
int main() {
int a, b;
std::bitset<5> aBs, bBs;
std::cout << "Enter two numbers between 0-31:" << std::endl;
std::cin >> a >> b;
if (a<0 || a>31) return -1;
if (b<0 || b>31) return -2;
aBs = static_cast<std::bitset<5>>(a);
bBs = static_cast<std::bitset<5>>(b);
// std::cout << aBs << " " << bBs << std::endl;
VerboseBinary aVB[6];
VerboseBinary bVB[6];
convert(aBs, aVB);
convert(bBs, bVB);
return 0;
}
나는 초보자는 매우 고무되지 않습니다 나는 왜 아무 이유에 주어지는 downvote에 대한 양성을 두 번 포함 있습니다. – IntegrateThis
주의 깊게 읽으십시오. http://stackoverflow.com/help/mcve 코드가 최소가 아닙니다. 오류가있는 코드 줄 번호를 쓰지 않았습니다. (나는 당신을 downvote하지 않았다) – SergV
어떤 Visual Studio 버전을 사용하고 있습니까? VS. 2012에서는'class '와 함께'enum'을 사용할 수있게되었습니다. 또한 enum의 정의 끝에 쉼표가 있습니다. 또한 stdafx.h는 verbose_binary.cpp에 다른 포함되기 전에 나타납니다. Main은 ''에 대한 이중 포함을 사용합니다. –