Elcric's Profile
Reputation: 100
Stalwart
- Group:
- Expert w/DIC++
- Active Posts:
- 453 (0.3 per day)
- Joined:
- 02-May 09
- Profile Views:
- 61,617
- Last Active:
May 10 2013 01:16 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Windows
- Favorite Browser:
- Internet Explorer
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- PC
- Your Car:
- Ford
- Dream Kudos:
- 2600
Latest Visitors
-
macosxnerd101 
07 Jun 2013 - 22:15 -
NoobKnight 
06 May 2013 - 10:36 -
Omega86 
29 Apr 2013 - 20:44 -
Raminator 
26 Apr 2013 - 11:47 -
skymonkier 
24 Apr 2013 - 11:51 -
fledgeling 
21 Apr 2013 - 05:59 -
mattylynch1 
15 Apr 2013 - 11:01 -
StaticCrazee 
11 Apr 2013 - 15:10 -
Damage 
12 Mar 2013 - 16:57 -
Nat3TheGreat13 
10 Mar 2013 - 10:50
Posts I've Made
-
In Topic: C++ STL BINARY PREDICATE FUNCTION TUTORIAL
Posted 25 Sep 2011
Ricky65, on 23 September 2011 - 06:42 PM, said:Just skimmed through it and I have a major problem.
You are wrong in stating that list, map and set are keywords; they are STL containers.
It pains me to see such fundamental errors from a tutorial.
In modern C++ (C++11) lambdas are the best way of applying predicates to STL algorithms. Unlike function pointers and function objects you can write your logic in place and unlike functions pointers the code will be inlined.
Consider this example using std::count_if:
int x [] = {3, 9, 11, 14, 7}; //return the number of elements in x which are greater than 5 and less than 10 auto test_count = std::count_if(std::begin(x), std::end(x), [] (int a) {return a > 5 && a < 10;});
It's just so easy. The STL algorithms become a factor of ten more usable (at least) with lambdas.
Thank you Ricky65. Good catch! I do not know where I picked up the habit of calling STL containers keywords. I goofed and I am sorry. I will review all of the other papers I have written. Thanks!
-
In Topic: C++ STL BINARY PREDICATE FUNCTION TUTORIAL
Posted 21 Sep 2011
DIC is my backup disk. Where is the rest of the Set Example code?
-
In Topic: GRAPHING ALGEBRAIC FUNCTIONS USING C++ AND FLTK TUTORIAL
Posted 1 Aug 2011
Hello laserbeak43,
Thank you very much for your comments:
laserbeak43, on 06 October 2010 - 12:18 AM, said:ok built it and got 2 errors, 67 successes and 1 sipped, my two errors are
Error 58 error c101008d: Failed to write the updated manifest to the resource of file "../test/labeld.exe". The operation failed. C:\flt\fltk-1.1.10\vc2005\mt.exe label Error 15 error LNK1181: cannot open input file 'fltkd.lib' C:\flt\fltk-1.1.10\vc2005\LINK line_style
I don't know the importance of a manifest, or if it even matters but for the fltkd.lib error, am i supposed to link the lib found in "../lib"?
I don't really see what's been skipped either. I'm stumped.
Thanks
If the example still does not work, please post your questions in the DIC forum and either I or someone else will help you. -
In Topic: BEGINNER C++ STL MAP AND MULTIMAP CONTAINER CLASSES TUTORIAL
Posted 1 Aug 2011
Hello Jovan,
Thank you for your comments:
Jovan, on 24 December 2010 - 01:05 AM, said:So for a class I'm doing (don't worry, it's extra credit for a Chemistry class, not a coding class), I'm making a program that calculates atomic mass based on the user inputting the symbols and amounts of each element involved in the molecule.
As an example, if the molecule that the user wants the atomic mass of is H2O, then I want them to be able to input "H" into the program, and "2" for the amount, and "O" and "1". The program is then supposed to go through the map I've created and find those values and calculate the mass and spit it out.
Firstly, I want to know if this is possible? Secondly, can you show me what to do, based on the code I have here:
#include <iostream> #include <string> #include <map> using namespace std; struct ElementInfo { std::string el_symbol; double el_mass; int el_number; ElementInfo( const std::string& name = "", int number = 0, double weight = 0) : el_symbol(name), el_mass(weight), el_number(number) {} }; typedef std::map<int, ElementInfo> PeriodicTable; enum { H, He, Li, Be, B, C, N, O, F, Ne, Na, Mg, Al, Si, P, S, Cl, Ar, K, Ca, Sc, Ti, V, Cr, Mn, Fe, Co, Ni, Cu, Zn, Ga, Ge, As, Se, Br, Kr, Rb, Sr, Y, Zr, Nb, Mo, Tc, Ru, Rh, Pd, Ag, Cd, In, Sn, Sb, Te, I, Xe, Cs, Ba, La, Ce, Pr, Nd, Pm, Sm, Eu, Gd, Tb, Dy, Ho, Er, Tm, Yb, Lu, Hf, Ta, W, Re, Os, Ir, Pt, Au, Hg, Tl, Pb, Bi, Po, At, Rn, Fr, Ra, Ac, Th, Pa, U, Np, Pu, Am, Cm, Bk, Cf, Es, Fm, Md, No, Lr, Rf, Db, Sg, Bh, Hs, Mt, Uun, Uuu, Uub, Uuq }; void InitializePeriodicTable( PeriodicTable& theTable) { theTable[H] = ElementInfo("H", 1, 1.0079); theTable[He] = ElementInfo("He", 2, 4.0026); theTable[Li] = ElementInfo("Li", 3, 6.941); theTable[Be] = ElementInfo("Be", 4, 9.0122); theTable[B] = ElementInfo("B", 5, 10.811); theTable[C] = ElementInfo("C", 6, 12.011); theTable[N] = ElementInfo("N", 7, 14.007); theTable[O] = ElementInfo("O", 8, 15.999); theTable[F] = ElementInfo("F", 9, 18.998); theTable[Ne] = ElementInfo("Ne", 10, 20.180); theTable[Na] = ElementInfo("Na", 11, 22.990); theTable[Mg] = ElementInfo("Mg", 12, 24.305); theTable[Al] = ElementInfo("Al", 13, 26.982); theTable[Si] = ElementInfo("Si", 14, 28.086); theTable[P] = ElementInfo("P", 15, 30.974); theTable[S] = ElementInfo("S", 16, 32.065); theTable[Cl] = ElementInfo("Cl", 17, 35.453); theTable[Ar] = ElementInfo("Ar", 18, 39.948); theTable[K] = ElementInfo("K", 19, 39.098); theTable[Ca] = ElementInfo("Ca", 20, 40.078); theTable[Sc] = ElementInfo("Sc", 21, 44.956); theTable[Ti] = ElementInfo("Ti", 22, 47.867); theTable[V] = ElementInfo("V", 23, 50.942); theTable[Cr] = ElementInfo("Cr", 24, 51.996); theTable[Mn] = ElementInfo("Mn", 25, 54.938); theTable[Fe] = ElementInfo("Fe", 26, 55.845); theTable[Co] = ElementInfo("Co", 27, 58.933); theTable[Ni] = ElementInfo("Ni", 28, 58.693); theTable[Cu] = ElementInfo("Cu", 29, 63.546); theTable[Zn] = ElementInfo("Zn", 30, 65.39); theTable[Ga] = ElementInfo("Ga", 31, 69.723); theTable[Ge] = ElementInfo("Ge", 32, 72.61); theTable[As] = ElementInfo("As", 33, 74.992); theTable[Se] = ElementInfo("Se", 34, 78.96); theTable[Br] = ElementInfo("Br", 35, 79.904); theTable[Kr] = ElementInfo("Kr", 36, 83.80); theTable[Rb] = ElementInfo("Rb", 37, 85.468); theTable[Sr] = ElementInfo("Sr", 38, 87.62); theTable[Y] = ElementInfo("Y", 39, 88.906); theTable[Zr] = ElementInfo("Zr", 40, 91.224); theTable[Nb] = ElementInfo("Nb", 41, 92.906); theTable[Mo] = ElementInfo("Mo", 42, 95.94); theTable[Tc] = ElementInfo("Tc", 43, 98.0); theTable[Ru] = ElementInfo("Ru", 44, 101.07); theTable[Rh] = ElementInfo("Rh", 45, 102.91); theTable[Pd] = ElementInfo("Pd", 46, 106.42); theTable[Ag] = ElementInfo("Ag", 47, 107.87); theTable[Cd] = ElementInfo("Cd", 48, 112.41); theTable[In] = ElementInfo("In", 49, 114.82); theTable[Sn] = ElementInfo("Sn", 50, 118.71); theTable[Sb] = ElementInfo("Sb", 51, 121.76); theTable[Te] = ElementInfo("Te", 52, 127.60); theTable[I] = ElementInfo("I", 53, 126.90); theTable[Xe] = ElementInfo("Xe", 54, 131.29); theTable[Cs] = ElementInfo("Cs", 55, 132.91); theTable[Ba] = ElementInfo("Ba", 56, 137.33); theTable[La] = ElementInfo("La", 57, 138.91); theTable[Ce] = ElementInfo("Ce", 58, 140.12); theTable[Pr] = ElementInfo("Pr", 59, 140.91); theTable[Nd] = ElementInfo("Nd", 60, 144.24); theTable[Pm] = ElementInfo("Pm", 61, 145.0); theTable[Sm] = ElementInfo("Sm", 62, 150.36); theTable[Eu] = ElementInfo("Eu", 63, 151.96); theTable[Gd] = ElementInfo("Gd", 64, 157.25); theTable[Tb] = ElementInfo("Tb", 65, 158.93); theTable[Dy] = ElementInfo("Dy", 66, 162.50); theTable[Ho] = ElementInfo("Ho", 67, 164.93); theTable[Er] = ElementInfo("Er", 68, 167.26); theTable[Tm] = ElementInfo("Tm", 69, 168.93); theTable[Yb] = ElementInfo("Yb", 70, 173.04); theTable[Lu] = ElementInfo("Lu", 71, 174.97); theTable[Hf] = ElementInfo("Hf", 72, 178.49); theTable[Ta] = ElementInfo("Ta", 73, 180.95); theTable[W] = ElementInfo("W", 74, 183.84); theTable[Re] = ElementInfo("Re", 75, 186.21); theTable[Os] = ElementInfo("Os", 76, 190.23); theTable[Ir] = ElementInfo("Ir", 77, 192.22); theTable[Pt] = ElementInfo("Pt", 78, 195.08); theTable[Au] = ElementInfo("Au", 79, 196.97); theTable[Hg] = ElementInfo("Hg", 80, 200.59); theTable[Tl] = ElementInfo("Tl", 81, 204.38); theTable[Pb] = ElementInfo("Pb", 82, 207.2); theTable[Bi] = ElementInfo("Bi", 83, 208.98); theTable[Po] = ElementInfo("Po", 84, 209.0); theTable[At] = ElementInfo("At", 85, 210.0); theTable[Rn] = ElementInfo("Rn", 86, 222.0); theTable[Fr] = ElementInfo("Fr", 87, 223.0); theTable[Ra] = ElementInfo("Ra", 88, 226.0); theTable[Ac] = ElementInfo("Ac", 89, 227.0); theTable[Th] = ElementInfo("Tc", 90, 232.04); theTable[Pa] = ElementInfo("Pa", 91, 231.04); theTable[U] = ElementInfo("U", 92, 238.03); theTable[Np] = ElementInfo("Np", 93, 237.0); theTable[Pu] = ElementInfo("Pu", 94, 244.0); theTable[Am] = ElementInfo("Am", 95, 143.0); theTable[Cm] = ElementInfo("Cm", 96, 247.0); theTable[Bk] = ElementInfo("Bk", 97, 247.0); theTable[Cf] = ElementInfo("Cf", 98, 251.0); theTable[Es] = ElementInfo("Es", 99, 252.0); theTable[Fm] = ElementInfo("Fm", 100, 257.0); theTable[Md] = ElementInfo("Md", 101, 258.0); theTable[No] = ElementInfo("No", 102, 259.0); theTable[Lr] = ElementInfo("Lr", 103, 262.0); theTable[Rf] = ElementInfo("Rf", 104, 261.0); theTable[Db] = ElementInfo("Db", 105, 262.0); theTable[Sg] = ElementInfo("Sg", 106, 266.0); theTable[Bh] = ElementInfo("Bh", 107, 264.0); theTable[Hs] = ElementInfo("Hs", 108, 269.0); theTable[Mt] = ElementInfo("Mt", 109, 268.0); theTable[Uun] = ElementInfo("Uun", 110, 271.0); theTable[Uuu] = ElementInfo("Uuu", 111, 272.0); theTable[Uub] = ElementInfo("Uub", 112, 277.0); theTable[Uuq] = ElementInfo("Uuq", 113, 289.0); } int main() { PeriodicTable myTable; InitializePeriodicTable( myTable ); int chemchoice, choicetwo; double choice, mass, grams, moles, atoms, x, molesk, ratio, molesu, massu, final; cout<<"\tChemistry Calculator 1.0\n\n"; cout<<"---------------------------------------------------------------------\n"; cout<<"1 - Mole/Gram/Atom Calculator\n"; cout<<"2 - Stoichiometry Calculator\n"; cout<<"---------------------------------------------------------------------\n"; cout<<"\nPlease type in your choice (1 or 2). To find out more information about either \n"; cout<<"choice, type 3: "; cin>>chemchoice; system("cls"); switch (chemchoice) { case 1: cout<<"\t\n\n\nMoles -- Grams -- Atoms Converter\n\n\n"; cout<<"There is a list of choices below:\n\n"; cout<<"1 - Grams to Moles\n"; cout<<"2 - Grams to Atoms\n"; cout<<"3 - Moles to Grams\n"; cout<<"4 - Moles to Atoms\n"; cout<<"5 - Atoms to Moles\n"; cout<<"6 - Atoms to Grams\n"; cout<<"\nPlease enter the number of your choice: "; cin>>choice; if (choice == 1) { cout<<"\n\nPlease enter the atomic mass of the atom: "; cin>>mass; cout<<"\nPlease enter the number of grams of the atom: "; cin>>grams; moles = grams / mass; cout<<"\n\nThe number of moles of this atom is: "<<moles<<"\n\n\n"; } else if (choice == 2) { cout<<"\n\nPlesase enter the grams of the atom: "; cin>>grams; cout<<"\nPease enter the atomic mass of the atom: "; cin>>mass; x = grams/mass; atoms = x * 6.022e+23; cout<<"\n\nThe number of atoms is: "<<atoms<<"\n\n\n"; } else if (choice == 3) { cout<<"\n\nPlease enter the atomic mass of the atom: "; cin>>mass; cout<<"\nPlease enter the number of moles of the atom: "; cin>>moles; grams = moles*mass; cout<<"\n\nThe number of grams of the atom is "<<grams<<"\n\n\n"; } else if (choice == 4) { cout<<"\n\nPlease enter the number of moles: "; cin>>moles; atoms = moles * 6.022e+23; cout<<"\n\nThe number of atoms is: "<<atoms<<"\n\n\n"; } else if (choice == 5) { cout<<"\n\nPlease enter the number of atoms (ex. 1.65*10^24 becomes 1.65e+24): "; cin>>atoms; moles = atoms / 6.022e+23; cout<<"\n\nThe number of moles is: "<<moles<<"\n\n\n"; } else if (choice == 6) { cout<<"\n\nPlease enter the number of atoms (ex. 1.65*10^24 becomes 1.65e+24): "; cin>>atoms; cout<<"\n\nPlease enter the atomic mass of the atom you want to convert: "; cin>>mass; moles = atoms / 6.022e+23; grams = moles * mass; cout<<"\n\nThe amount (in grams) of the atom is: "<<grams<<"\n\n\n"; } else { cout <<"Error - Invalid input; only 1 or 2 allowed.\n"; } system ("pause"); return 0; break; case 2: cout<<"\t\n\n\nStoichiometry Calculator\n\n\n"; cout<<"Enter the amount (in grams) of the known compound: "; cin>>grams; cout<<"\nEnter the atomic mass of the known compound: "; cin>>mass; molesk=grams/mass; cout<<"\nEnter the mole ratio of UNKOWN compound to KNOWN compound (Use the coefficient \n"; cout<<"from the balanced equation). Enter in decimal format: "; cin>>ratio; molesu=molesk*ratio; cout<<"\nEnter the atomic mass of the unkown compound (in grams): "; cin>>massu; final=molesu*massu; cout<<"\nThe final answer is: "<<final<<"\n\n\n"; system ("pause"); return 0; break; case 3: cout<<"Which would you like to find out more about?\n"; cout<<"\n1 - The Mole/Gram/Atom Calculator\n"; cout<<"2 - The Stoichiometry Calculator\n"; cout<<"\nPlease type in your answer (1 or 2): "; cin>>choicetwo; } switch (choicetwo) { case 1: cout<<"\n\nThis calculator does many different conversions between Atoms, Grams and Moles.\n"; break; case 2: cout<<"This calculator recieves your input and gives you the answer to a Stoichiometric problem.\n"; break; } cout<<"\n\n\n---------------------------------------------------------------------\n"; cout<<"1 - Mole/Gram/Atom Calculator\n"; cout<<"2 - Stoichiometry Calculator\n"; cout<<"---------------------------------------------------------------------\n"; cout<<"\nPlease type in your choice (1 or 2). To find out more information about either \n"; cout<<"choice, type 3: "; cin>>chemchoice; system("cls"); switch (chemchoice) { case 1: cout<<"\t\n\n\nMoles -- Grams -- Atoms Converter\n\n\n"; cout<<"There is a list of choices below:\n\n"; cout<<"1 - Grams to Moles\n"; cout<<"2 - Grams to Atoms\n"; cout<<"3 - Moles to Grams\n"; cout<<"4 - Moles to Atoms\n"; cout<<"5 - Atoms to Moles\n"; cout<<"6 - Atoms to Grams\n"; cout<<"\nPlease enter the number of your choice: "; cin>>choice; if (choice == 1) { cout<<"\n\nPlease enter the atomic mass of the atom: "; cin>>mass; cout<<"\nPlease enter the number of grams of the atom: "; cin>>grams; moles = grams / mass; cout<<"\n\nThe number of moles of this atom is: "<<moles<<"\n\n\n"; } else if (choice == 2) { cout<<"\n\nPlesase enter the grams of the atom: "; cin>>grams; cout<<"\nPease enter the atomic mass of the atom: "; cin>>mass; x = grams/mass; atoms = x * 6.022e+23; cout<<"\n\nThe number of atoms is: "<<atoms<<"\n\n\n"; } else if (choice == 3) { cout<<"\n\nPlease enter the atomic mass of the atom: "; cin>>mass; cout<<"\nPlease enter the number of moles of the atom: "; cin>>moles; grams = moles*mass; cout<<"\n\nThe number of grams of the atom is "<<grams<<"\n\n\n"; } else if (choice == 4) { cout<<"\n\nPlease enter the number of moles: "; cin>>moles; atoms = moles * 6.022e+23; cout<<"\n\nThe number of atoms is: "<<atoms<<"\n\n\n"; } else if (choice == 5) { cout<<"\n\nPlease enter the number of atoms (ex. 1.65*10^24 becomes 1.65e+24): "; cin>>atoms; moles = atoms / 6.022e+23; cout<<"\n\nThe number of moles is: "<<moles<<"\n\n\n"; } else if (choice == 6) { cout<<"\n\nPlease enter the number of atoms (ex. 1.65*10^24 becomes 1.65e+24): "; cin>>atoms; cout<<"\n\nPlease enter the atomic mass of the atom you want to convert: "; cin>>mass; moles = atoms / 6.022e+23; grams = moles * mass; cout<<"\n\nThe amount (in grams) of the atom is: "<<grams<<"\n\n\n"; } else { cout <<"Error - Invalid input; only 1 or 2 allowed.\n"; } system ("pause"); return 0; break; case 2: cout<<"\t\n\n\nStoichiometry Calculator\n\n\n"; cout<<"Enter the amount (in grams) of the known compound: "; cin>>grams; cout<<"\nEnter the atomic mass of the known compound: "; cin>>mass; molesk=grams/mass; cout<<"\nEnter the mole ratio of UNKOWN compound to KNOWN compound (Use the coefficient \n"; cout<<"from the balanced equation). Enter in decimal format: "; cin>>ratio; molesu=molesk*ratio; cout<<"\nEnter the atomic mass of the unkown compound (in grams): "; cin>>massu; final=molesu*massu; cout<<"\nThe final answer is: "<<final<<"\n\n\n"; system ("pause"); return 0; break; case 3: cout<<"Which would you like to find out more about?\n"; cout<<"\n1 - The Mole/Gram/Atom Calculator\n"; cout<<"2 - The Stoichiometry Calculator\n"; cout<<"\nPlease type in your answer (1 or 2): "; cin>>choicetwo; } switch (choicetwo) { case 1: cout<<"\n\nThis calculator does many different conversions between Atoms, Grams and Moles.\n"; break; case 2: cout<<"This calculator recieves your input and gives you the answer to a Stoichiometric problem.\n"; break; } }
If your program still does not work, please post your questions in the DIC forum and either I or someone else will help you. -
In Topic: C++ 3D ANIMATION FLTK OPENGL TUTORIAL
Posted 1 Aug 2011
Hello kxng66,
Thank you very much for your comments:
kxng66, on 03 February 2011 - 05:28 PM, said:Hello,
I am struggling in setting up the fltk opengl in VC++. I followed your instruction, it still generate many linking errors. Can you send me your sample project in VC++ 6.0 as my starting point? Otherwise, can you walk me step by step in setting it up?
I can run fltk in VC++ 6.0 but once I added fl_gl_window object in my code, problem occurs.
Thanks in advance,
Giau
If the example still does not work, please post your questions in the DIC forum and either I or someone else will help you.
My Information
- Member Title:
- D.I.C Regular
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Interests:
- C, C++, Haskell, and Python
- Programming Languages:
- C, C++, Haskell, and Python.
Contact Information
Friends
-

born2c0de
-

WolfCoder
-

Jhin
-

Bort
-

AmitTheInf...
-

Martyr2
-

flipper798
-

cfoley
-

T3hC13h
-

stayscrisp
-

AdaHacker
-

megglz
-

psychicrox
-

SixOfEleven
-

alienDevel...
-

coden4fun
-

du_jleon
-

imfarhan
-

renuthakur...
-

ShaneK
-

jjl
-

Laythe
-

NoobKnight
-

CodeWomanS...
-

ghghgh
-

Mercurial
-

kowwok
-

omart
-

yaw49
-

demosthene...
-

RandomlyKn...
-

bcranger
-

1Timmy
-

rahul3
-

eramitpatni
-

Ember
-

Kilorn
-

webpeater
-

Manbearpig101
-

Eclipse Re...
-

RyldValas
-

javadork
-

Felix_Violo
-

kaye143
-

nandureddy
-

scolty
-

sociallyaw...
-

lovelyxalice
-

Jexpos
-

Fredex
Showing 50 random friends of 417 (View all)
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
rangerofthewest
13 Sep 2012 - 06:20DimitriV
14 Nov 2011 - 17:36brep
09 Sep 2011 - 11:07Vator
27 Jul 2011 - 17:09ishkabible
30 Jan 2011 - 10:15jeremejazz
29 Dec 2010 - 23:09Munawwar
09 Oct 2010 - 13:26grimpirate
22 Sep 2010 - 23:34cordwell
14 Sep 2010 - 21:05Alex6788
13 Sep 2010 - 23:57alias120
10 Sep 2010 - 17:48magam
26 Jul 2010 - 05:07Searock
21 Jul 2010 - 07:59simeesta
12 Jul 2010 - 15:52jteneso
11 Jul 2010 - 07:33