Click here to Skip to main content
15,892,059 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Question[newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 4:16
professionaljon-8013-Jun-09 4:16 
AnswerRe: [newbie] error C2065: 'b' : undeclared identifier Pin
Luc Pattyn13-Jun-09 4:46
sitebuilderLuc Pattyn13-Jun-09 4:46 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 4:52
professionaljon-8013-Jun-09 4:52 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
Randor 13-Jun-09 5:15
professional Randor 13-Jun-09 5:15 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 5:18
professionaljon-8013-Jun-09 5:18 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
Luc Pattyn13-Jun-09 14:32
sitebuilderLuc Pattyn13-Jun-09 14:32 
AnswerRe: [newbie] error C2065: 'b' : undeclared identifier Pin
N a v a n e e t h13-Jun-09 4:48
N a v a n e e t h13-Jun-09 4:48 
Question[newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 4:12
professionaljon-8013-Jun-09 4:12 
Any idea why this code doesn't compile?

<pre>
// SieveOfErathostenes.cpp : main project file.

#include "stdafx.h"
#include &lt;bitset&gt;
#include &lt;iostream&gt;
#include &lt;ctime&gt;

using namespace System;

int main(array&lt;System::String ^&gt; ^args)
{
const int N = 2000000;
clock_t cstart = clock();

bitset&lt;N + 1&gt; b;
int count = 0;
int i;
for (i = 2; i &lt;= N; i++)
b.set(i);
i = 2;

while (i * i &lt;= N)
{
if (b.test(i))
{
count++;
int k = 2 * i;
while (k &lt;= N)
{
b.reset(k);
k += i;
}
}
i++;
}

while (i &lt;= N)
{
if (b.test(i)) count++;
i++;
}

clock_t cend = clock();
double millis = 1000.0 * (cend - cstart) / CLOCKS_PER_SEC;

cout &lt;&lt; count &lt;&lt; " primes \n" &lt;&lt; millis &lt;&lt; " milliseconds\n";

return 0;
}

</pre>

Errors:
Error 4 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes


Error 5 error C2228: left of '.set' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes


Error 6 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes


Error 7 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes


Error 8 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes


Error 9 error C2228: left of '.reset' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes


Error 10 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes


Error 11 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes


Error 12 error C2065: 'cout' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 46 SieveOfErathostenes

NOTE:
1. Core Java Vol I 8th Ed. Pg. 713 (727)

Jon

AnswerRe: [newbie] error C2065: 'b' : undeclared identifier Pin
dybs13-Jun-09 5:20
dybs13-Jun-09 5:20 
QuestionDataGrid1 column width Pin
wael_r12-Jun-09 23:36
wael_r12-Jun-09 23:36 
QuestionRunning apps remotely (CLI) Pin
See_Sharp12-Jun-09 10:51
See_Sharp12-Jun-09 10:51 
AnswerRe: Running apps remotely (CLI) Pin
Randor 12-Jun-09 12:55
professional Randor 12-Jun-09 12:55 
GeneralRe: Running apps remotely (CLI) Pin
See_Sharp12-Jun-09 13:30
See_Sharp12-Jun-09 13:30 
QuestionLabel flickering Pin
cherrymotion11-Jun-09 21:56
cherrymotion11-Jun-09 21:56 
AnswerRe: Label flickering Pin
Luc Pattyn12-Jun-09 2:59
sitebuilderLuc Pattyn12-Jun-09 2:59 
GeneralRe: Label flickering Pin
cherrymotion12-Jun-09 3:34
cherrymotion12-Jun-09 3:34 
GeneralRe: Label flickering Pin
Luc Pattyn12-Jun-09 3:40
sitebuilderLuc Pattyn12-Jun-09 3:40 
GeneralRe: Label flickering Pin
cherrymotion12-Jun-09 4:34
cherrymotion12-Jun-09 4:34 
GeneralRe: Label flickering Pin
Luc Pattyn12-Jun-09 4:50
sitebuilderLuc Pattyn12-Jun-09 4:50 
QuestionAvoid if else... Pin
vikasvds11-Jun-09 2:19
vikasvds11-Jun-09 2:19 
AnswerRe: Avoid if else... [modified] Pin
thoru11-Jun-09 3:17
thoru11-Jun-09 3:17 
AnswerRe: Avoid if else... Pin
led mike11-Jun-09 4:36
led mike11-Jun-09 4:36 
AnswerRe: Avoid if else... Pin
LionAM13-Jun-09 21:25
LionAM13-Jun-09 21:25 
GeneralRe: Avoid if else... Pin
vikasvds14-Jun-09 21:36
vikasvds14-Jun-09 21:36 
QuestionRun external executable file in C++ Pin
wael_r11-Jun-09 2:11
wael_r11-Jun-09 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.