Hi All
I'm new to C++.
I tried to write the following code:
<-- snip --
#include <cmath>
#include <iostream>
template < class K, class Y >
void NumerovIntegrate ( const K &k2, Y &y0, Y &y1, double &x0, double h,
unsigned int N ) {
<Y> y0_temp;
for (int i=1; i<=N; i++) {
y0_temp = y1;
y1 = 1/(1+h*h/12*sqr(k2(x0+2*h)))*(2*(1-5*h*h/12*sqr(k(x0+h)))*y1-(1
+h*h/12*sqr(k(x0)))*y0);
y0 = y0_temp;
x = x0+h;
}
}
-- snap --
G++ tells me:
-
pascal@thinkpad ~/rgp
$ g++ Numerov.cpp
Numerov.cpp: In function `void NumerovIntegrate(const K&, Y&, Y&,
double&,
double, unsigned int)':
Numerov.cpp:6: error: syntax error before `<' token
-
-
pascal@thinkpad ~/rgp
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /GCC/gcc-3.3.1-3/configure --with-gcc --with-gnu-ld --
with-gnu-
as --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
--libexe
cdir=/usr/sbin --mandir=/usr/share/man --infodir=/usr/share/info --
enable-langua
ges=c,ada,c++,f77,pascal,java,objc --enable-libgcj --enable-
threads=posix --with
-system-zlib --enable-nls --without-included-gettext --enable-
interpreter --enab
le-sjlj-exceptions --disable-version-specific-runtime-libs --enable-
shared --dis
able-win32-registry --enable-java-gc=boehm --disable-hash-
synchronization --verb
ose --target=i686-pc-cygwin --host=i686-pc-cygwin --build=i686-pc-cygwin
Thread model: posix
gcc version 3.3.1 (cygming special)
---
Can anyone help me please?
Thanks!
Pascal 6 1541
Pascal Steiss wrote: Hi All
I'm new to C++. I tried to write the following code:
<-- snip --
#include <cmath> #include <iostream>
template < class K, class Y > void NumerovIntegrate ( const K &k2, Y &y0, Y &y1, double &x0, double h, unsigned int N ) { <Y> y0_temp;
There should be no angle brackets in the line above.
--
Mike Smith
"Pascal Steiss" <pa***********@gmx.ch> wrote in message news:bt************@ID-122033.news.uni-berlin.de... I'm new to C++. I tried to write the following code:
Always helpful to us to mark what line ther error message is. Counting
lines is tedious and blank lines tend to come and go in email formatting.
<Y> y0_temp;
I suspect this is the problem.
Y y0_temp;
is what you really want.
Pascal Steiss wrote: Hi All
I'm new to C++. I tried to write the following code:
<-- snip --
#include <cmath> #include <iostream>
template < class K, class Y > void NumerovIntegrate ( const K &k2, Y &y0, Y &y1, double &x0, double h, unsigned int N ) { <Y> y0_temp;
ITYM:
Y y0_temp;
for (int i=1; i<=N; i++) { y0_temp = y1; y1 = 1/(1+h*h/12*sqr(k2(x0+2*h)))*(2*(1-5*h*h/12*sqr(k(x0+h)))*y1-(1 +h*h/12*sqr(k(x0)))*y0); y0 = y0_temp; x = x0+h; } }
[snip]
HTH,
--ag
--
Artie Gold -- Austin, Texas
Mike Smith schrieb: Pascal Steiss wrote:
Hi All
I'm new to C++. I tried to write the following code:
<-- snip --
#include <cmath> #include <iostream>
template < class K, class Y > void NumerovIntegrate ( const K &k2, Y &y0, Y &y1, double &x0, double h, unsigned int N ) { <Y> y0_temp;
There should be no angle brackets in the line above.
Sorry for my stupidity - but now G++ tells me
-- snip --
pascal@thinkpad ~/rgp
$ g++ Numerov.cpp
/usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../libcygwin.a(libcmain.o)
(.text+0x7
c): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
-- snap --
What does this mean?
Is this a G++_ON_CYGWIN Bug?
Pascal
"Pascal Steiss" <pa***********@gmx.ch> wrote in message
news:bt************@ID-122033.news.uni-berlin.de... Mike Smith schrieb:
Pascal Steiss wrote:
Hi All
I'm new to C++. I tried to write the following code:
<-- snip --
#include <cmath> #include <iostream>
template < class K, class Y > void NumerovIntegrate ( const K &k2, Y &y0, Y &y1, double &x0, double h, unsigned int N ) { <Y> y0_temp;
There should be no angle brackets in the line above.
Sorry for my stupidity - but now G++ tells me -- snip --
pascal@thinkpad ~/rgp $ g++ Numerov.cpp /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/../../../libcygwin.a(libcmain.o) (.text+0x7 c): undefined reference to `_WinMain@16' collect2: ld returned 1 exit status
-- snap --
What does this mean? Is this a G++_ON_CYGWIN Bug?
Pascal
That is because you created a windows project... set the project type to dos
(console) and create a main function (remember, main returns _int_).
HTH,
S. Armondi
This :
<Y> y0_temp;
should be:
Y y0_temp; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike420 |
last post by:
I think everyone who used Python will agree that its syntax is
the best thing going for it. It is very readable and easy
for everyone to learn. But, Python does not a have very good
macro...
|
by: C. Barnes |
last post by:
I vote for
def f():
(body of function)
This is backwards compatible (Python <= 2.3 raise
SyntaxError), and looks much nicer than @.
The only problem is that you can't one-line a...
|
by: Tongu? Yumruk |
last post by:
I have a little proposal about type checking in python. I'll be glad
if you read and comment on it. Sorry for my bad english (I'm not a
native English speaker)
A Little Stricter Typing in Python...
|
by: shank |
last post by:
1) I'm getting this error: Syntax error (missing operator) in query
expression on the below statement. Can I get some advice.
2) I searched ASPFAQ and came up blank. Where can find the "rules"...
|
by: PeterX |
last post by:
Luban: A new scripting language with C++ syntax and Java Bean like
objec model
Luban is a new component oriented scripting language recently created
by Xiaochuan(Peter) Huang in New Jersey,...
| |
by: Dan Trowbridge |
last post by:
Hi everyone,
In my attempt to port code from VS 6.0 to VS.NET I had some code break along
the way, mostly due to not adhereing closely to the C++ standard. This may
be another instance but I...
|
by: Brett Sinclair |
last post by:
Hello everybody
I'm still on the learning curve here...and from what I read, I created
inherited datagrid class so I could have icons, combobox...etc in the
columns of my datagrid.
The grid...
|
by: mattmao |
last post by:
I am moving onto the tough part in learning C:(
First, about the declaration of a user defined structure:
I found this syntax in my lecture notes:
struct userinfo
{
char username;
...
|
by: miller.paul.w |
last post by:
Ruby has a neat little convenience when writing loops where you don't
care about the loop index: you just do n.times do { ... some
code ... } where n is an integer representing how many times you...
|
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,...
|
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...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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 project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |