473,770 Members | 5,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compile error " instantiated from here"

Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
.../stddev.cpp: In member function 'int
StatUtils::std_ dev(std::vector <int, std::allocator< int> >&, int,
int)':
.../stddev.cpp:206: warning: converting to 'int' from 'double'
.../stddev.cpp:215: warning: converting to 'int' from 'double'
.../stddev.cpp:218: warning: converting to 'int' from 'double'
.../stddev.cpp: In member function 'int
StatUtils::mean (std::vector<in t, std::allocator< int> >&, int, int)':
.../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_numeric.h:
In function '_Tp std::accumulate (_InputIterator , _InputIterator, _Tp,
_BinaryOperatio n) [with _InputIterator =
__gnu_cxx::__no rmal_iterator<i nt*, std::vector<int , std::allocator< int>
, _Tp = double, _BinaryOperatio n = do_std_dev<int>]':

.../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function <T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_ dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::it erator startIter = v.begin();
vector<int>::it erator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int> (mean2));

return stdDevSum;
}

Feb 13 '06 #1
2 8984
> [...]
../stddev.cpp:215: warning: converting to 'int' from 'double'
[...]


I recommend you provide a complete minimal example without any
conversion-from-int-to-double-issue. Focus e.g. on int first. As far
as I see the conversion is of no relevance for the
standard-deviation-feature you want to have. Maybe clearing the
conversion-issue already leads to a working program.

Feb 13 '06 #2
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
ke*********@gma il.com wrote:
Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
../stddev.cpp: In member function 'int
StatUtils::std_ dev(std::vector <int, std::allocator< int> >&, int,
int)':
../stddev.cpp:206: warning: converting to 'int' from 'double'
../stddev.cpp:215: warning: converting to 'int' from 'double'
../stddev.cpp:218: warning: converting to 'int' from 'double'
../stddev.cpp: In member function 'int
StatUtils::mean (std::vector<in t, std::allocator< int> >&, int, int)':
../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_nu
meric.h:
In function '_Tp std::accumulate (_InputIterator , _InputIterator, _Tp,
_BinaryOperatio n) [with _InputIterator =
__gnu_cxx::__no rmal_iterator<i nt*, std::vector<int , std::allocator< int>
, _Tp = double, _BinaryOperatio n = do_std_dev<int>]':

../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function <T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_ dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::it erator startIter = v.begin();
vector<int>::it erator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int> (mean2));

return stdDevSum;
}


Look at the template for accumulate and remember that "0.0" is a double
whereas "0" is an int. What type does accumulate return?

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 13 '06 #3

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

Similar topics

2
3077
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run it... Segmentation fault (core dumped) I've located where the problem is... It is part of the following function's
2
7868
by: Happy Li | last post by:
Need help! I have a project with one crystal report. How can I compile it with csc.exe. I have tried the following command line .it compile successfully..but when I run, it display error 'Unable to find the report in the manifest resources'. csc.exe /target:exe /resource:source\abc.rpt,abcsystem.abc.rpt /lib:"C:\Program Files\Common Files\Crystal Decisions\1.1\Managed"...
5
4974
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
3
8835
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
4
3970
by: Bill Coan | last post by:
NOTE: This was posted earlier to vsnet.vstools.office under a different subject line but received no response. I'm having a problem automating Word's Find object from a .NET application, using late binding. If I use early binding, my code runs fine on most systems, but it is vulnerable to a known bug explained here: http://support.microsoft.com/default.aspx?scid=kb;en-us;292744
10
3737
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server Error in '/QuickStartv20' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file
1
657
by: ken.carlino | last post by:
Hi, I have the following compile error instantiated from here, I appreciate if someone can help me find out why? g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp .../stddev.cpp: In member function 'int StatUtils::std_dev(std::vector<int, std::allocator<int> >&, int, int)': .../stddev.cpp:206: warning: converting to 'int' from 'double'
3
2346
by: tony | last post by:
Hello! When I build an exe file that use 6 class library dll I get this error. Could not copy temporary files to the output directory. The file 'MeltPracStorage.dll' cannot be copied to the run directory. Det går inte att komma åt filen eftersom den används av en annan process. All six project is located in the solution that build the exe file This compile error occurred when I add project 'MeltPracStorage to the
6
1775
by: JHNielson | last post by:
This is a very simple question.... I have a form that looks up Records for an unbound drop-down list. It has worked just fine up until last night. Now the button on the form to delete a record doesn't work. i get a "compile error: method or data member not found". The code for the drop-down is this: Private Sub REC_ID_COMBO_AfterUpdate()
0
2037
by: yyuan168a | last post by:
I'm upgrading a VS2003 project to VS2005 but got bunch of C2039 errors in xutility.h file during compiling: :\Program Files\Microsoft Visual Studio 8\VC\include\xutility(610) : error C2039: 'iterator_category' : is not a member of 'ObjectBaseIteratorCL' c:\caps91\interfac\..\interfac\objmgr.h(2070) : see declaration of 'ObjectBaseIteratorCL' C:\Program Files\Microsoft Visual Studio 8\VC\include\xutility(2357) : see reference...
0
9591
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10225
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10001
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
9867
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
8880
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 project—planning, coding, testing, and deployment—without 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...
1
7415
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3969
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
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
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.