-
February 9th, 2009, 01:16 AM
#1
newbie on VC++ 2008
i'm trying to create a simple program for VC++ 2008. It's been years since i last did a program in C++ and i've never used 2008 before except yesterday. I've been trying to remove these errors for hours already. I'm suppose to take an exam on it today but i still can't run the program. someone told me that i should post this topic here... HELP me pls!
// jkhui.h
#pragma once
#include "stdafx.h"
#include <iostream>
#include "string.h"
using namespace std;
int main;
namespace jkhui{
public class Class1
{
// TODO: Add your methods for this class here.
{
long n, f, i;
cout;//"Enter No: \n"
cin ;//n
(i=n i>=1 i--)
f = f*1
cout ;//f;
}
};
}
and these are the errors i received...
1>------ Build started: Project: jkhui, Configuration: Debug Win32 ------
1>Compiling...
1>jkhui.cpp
1>c:\documents and settings\acer valued client\my documents\visual studio 2008\projects\jkhui\jkhui\jkhui.h(14) : error C2059: syntax error : '{'
1>c:\documents and settings\acer valued client\my documents\visual studio 2008\projects\jkhui\jkhui\jkhui.h(14) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
1>Build log was saved at "file://c:\Documents and Settings\acer valued client\My Documents\Visual Studio 2008\Projects\jkhui\jkhui\Debug\BuildLog.htm"
1>jkhui - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I have a feeling that I'm missing something but I just can't find it. HELP please...
-
February 9th, 2009, 06:12 AM
#2
Re: newbie on VC++ 2008
1. Please use code tags in future.
2. There are lots of things wrong
Firstly you haven't defined a method in your class for your code. You can't just put code into a class like you have without defining a method for it.
Secondly you haven't defined a main method for your application. Therefore your application doesn't know which code to run on startup.
Thirdly std::cin and std::cout are used with the << and >> operators e.g.
Code:
int length = 0;
std::cin >> length;
std::cout << length;
Lastly the line
makes no sense at all. Do you intend a for loop ? In which case the format should be :
Code:
for (i=n i>=1 i--)
{
// code to run every iteration goes in here
}
Darwen.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|