Click here to Skip to main content
15,905,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCompare Images. Pin
FISH78613-Jun-09 5:18
FISH78613-Jun-09 5:18 
AnswerRe: Compare Images. Pin
Randor 13-Jun-09 6:12
professional Randor 13-Jun-09 6:12 
AnswerRe: Compare Images. Pin
PJ Arends13-Jun-09 6:29
professionalPJ Arends13-Jun-09 6:29 
QuestionCreating a MFC "Static" Dill Pin
Larry Mills Sr13-Jun-09 4:35
Larry Mills Sr13-Jun-09 4:35 
AnswerRe: Creating a MFC "Static" Dill Pin
Randor 13-Jun-09 5:50
professional Randor 13-Jun-09 5:50 
GeneralRe: Creating a MFC "Static" Dill Pin
Larry Mills Sr13-Jun-09 16:08
Larry Mills Sr13-Jun-09 16:08 
GeneralRe: Creating a MFC "Static" Dill Pin
Randor 13-Jun-09 18:24
professional Randor 13-Jun-09 18:24 
Question[newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 3:23
professionaljon-8013-Jun-09 3:23 
Any idea why this code doesn't compile?

// SieveOfErathostenes.cpp : main project file.

#include "stdafx.h"
#include <bitset>
#include <iostream>
#include <ctime>

using namespace System;

int main(array<System::String ^> ^args)
{
    const int N = 2000000;
    clock_t cstart = clock();

    bitset<N + 1> b;
    int count = 0;
    int i;
    for (i = 2; i <= N; i++)
        b.set(i);
    i = 2;

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

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

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

    cout << count << " primes \n" << millis << " milliseconds\n";

    return 0;
}


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
CPallini13-Jun-09 4:09
mveCPallini13-Jun-09 4:09 
AnswerRe: [newbie] error C2065: 'b' : undeclared identifier Pin
Stuart Dootson13-Jun-09 13:05
professionalStuart Dootson13-Jun-09 13:05 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
jon-8013-Jun-09 21:19
professionaljon-8013-Jun-09 21:19 
GeneralRe: [newbie] error C2065: 'b' : undeclared identifier Pin
Stuart Dootson14-Jun-09 2:16
professionalStuart Dootson14-Jun-09 2:16 
Question__declspec(dllimport) Pin
_808613-Jun-09 1:50
_808613-Jun-09 1:50 
AnswerRe: __declspec(dllimport) Pin
Randor 13-Jun-09 5:27
professional Randor 13-Jun-09 5:27 
GeneralRe: __declspec(dllimport) Pin
_808613-Jun-09 21:47
_808613-Jun-09 21:47 
GeneralRe: __declspec(dllimport) Pin
_808614-Jun-09 4:46
_808614-Jun-09 4:46 
GeneralRe: __declspec(dllimport) Pin
Randor 14-Jun-09 5:20
professional Randor 14-Jun-09 5:20 
QuestionCalling DLL function that is not imported(MFC and WinMain) Pin
sawerr13-Jun-09 0:50
sawerr13-Jun-09 0:50 
AnswerRe: Calling DLL function that is not imported(MFC and WinMain) Pin
sgenie6813-Jun-09 1:13
sgenie6813-Jun-09 1:13 
AnswerRe: Calling DLL function that is not imported(MFC and WinMain) Pin
Rajesh R Subramanian13-Jun-09 2:26
professionalRajesh R Subramanian13-Jun-09 2:26 
GeneralRe: Calling DLL function that is not imported(MFC and WinMain) Pin
sawerr13-Jun-09 3:17
sawerr13-Jun-09 3:17 
GeneralRe: Calling DLL function that is not imported(MFC and WinMain) Pin
sgenie6813-Jun-09 22:22
sgenie6813-Jun-09 22:22 
QuestionHow to open a logical partition and read all of its file using windows function ReadFile() ? Pin
krish_kumar12-Jun-09 22:53
krish_kumar12-Jun-09 22:53 
QuestionRe: How to open a logical partition and read all of its file using windows function ReadFile() ? Pin
Randor 13-Jun-09 5:38
professional Randor 13-Jun-09 5:38 
AnswerRe: How to open a logical partition and read all of its file using windows function ReadFile() ? Pin
krish_kumar13-Jun-09 6:27
krish_kumar13-Jun-09 6:27 

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.