473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What's wrong with this program?

Could you tell me what's wrong with this program, it doesn't compile:

#include <iostream>
#include <cstdlib>
using namespace std;

class Everything
{
public:
static Everything* Instance()
{
if(instance==0)
instance=new Everything;
return instance;
}
const long double pi;
const long double e;
const long double phi;
private:
Everything():pi (3.14591),e(2.7 1828),phi(1.618 034){}
Everything(cons t Everything&);
Everything& operator=(const Everything&);
private:
static Everything* instance;
};
Everything* Everything::ins tance = 0;// initialize pointer

Everything* var=Instance();
int main()
{
long double* area(const long double& radius, const Everything* var);
long double rad;
cout << "Enter a radius: ";
cin >> rad;
long double* ret=area(rad,va r);
cout << "Area: " << *ret << endl;
delete ret;
system("PAUSE") ;
return EXIT_SUCCESS;
}
long double* area(const long double& radius, const Everything* var)
{
template<class T>T Exp(const T& base,long long exp);
long double* ret=new long double(var->pi*Exp<long double>(radius, 2));
return ret;
}
template<class T>
T Exp(const T& base,long long exp)
{
for(T i=1;exp>0;exp--)
i*=base;
return i;
}

Any suggestions? Thanks!!!

Nov 22 '05
10 3236
"Protoman" <Pr**********@g mail.com> writes:
Never mind, I fixed that, now its saying that var is undeclared in the
area function and that's there's a missing semicolon and stuff.
Here's the code:

#include <iostream>
#include <cstdlib>
using namespace std;

template<class T>
T Exp(const T& base,long long exp)


When getting loads of errors, the best recipie is usually to fix
the first one, and then recompile. I tried your source, and am
willing to help you with the first one:

protoman.cc:7: error: ISO C++ does not support `long long'

The best way to fix a compile error is not to post garbage code to
clc++, but to read the error message, try to understand what
it says, then try to understand why it says so, and finally
fix the corresponding line of code.

Step one: "protoman.c c:7: error: ISO C++ does not support `long long'"

This means that there is something with the file 'protoman.cc'
(which is what I named it on my computer, it might be something
else on your).

That something happens at (or near) line 7, and it is an 'error'
(which is my compiler's way of saying: "I refuse to output any
result (other than compiler messages)". It could have said
warning, which would have meant: "Maybe an error, you decide".

The message is "ISO C++ does not support `long long'"

This means that there is no type named long long in C++.
The line in question reads: "T Exp(const T& base,long long exp)"

At the end immediatly before the token 'exp' it says long long.
The obvious way to fix this is to change either to a type that
exists in the language, or to a user defined type.

Now fix this, recompile, and then repeat the process until there
are no errors left.

If there is some specific error message you really don't understand,
post that message together with a minimal code sample that produce
that error, and you might find some more help here, or perhaps you'll
find out what it means in the process of minimizing the code sample.

By the way, please post properly indented code next time.

/Niklas Norrthon
Nov 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

137
7182
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
125
14850
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
5
2836
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
1
2144
by: Qiangning Hong | last post by:
I decide to seperate my data collection routine from my data analysis and storage program to a seperate process, so I try to use the new subprocess model in Python 2.4. The main program spawns the subprocess and receives data from the pipe. When some event occurs (e.g. the user clicks the 'Stop' button on GUI), the main program will send the subprocess a command to change its behavior or ask it to exit. However, my code (attached...
46
4261
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do believe MSFT should do to improve C#, however. I know that in the "Whidbey" release of VS.NET currently
669
26212
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
3
2750
by: belton180 | last post by:
CODE]../* Program function: Simulate the stack using a stack limit of 10. Display a menu for the the following. Create a stack Insert an item in the stack Pop an item from the stack Peep/view the item at the top of the stack Current value of top View all items stored in the stack Quit *the stack accepts lowercase & uppercase characters only from A-Z
20
2820
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
12
2113
by: broli | last post by:
#include<stdio.h> #include<stdlib.h> struct point { double x, y, z;
4
1966
by: hirsh.dan | last post by:
i have a functions that writes information to a file. inside that function i have a line in which i call another function. if this line is executed, nothing is written to the file, but if i remark that line, it is written. i wanna understand what's wrong and fix it, but can't find what is wrong. also this line is mandatory in my code. the code attached is in the link, minimized to the needed info, a bit different then the way it's...
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.