Can anyone please suggest some good C++ coverage tool. I am basically looking tool that really works fine when it comes to unit testing. The tool should work in the linux environment
Is it possible via script/tool to generate a delete statement based on the tables fk relations.
i.e. I have the table: DelMe(ID) and there are 30 tables with fk references to its ID that I need to delete first, is there some tool/script that I can run that will generate the 30 delete statements based on the FK relations for me ?
(btw I know about cascade delete on the relations, I can't use it in this existing db)
I'm using Microsoft SQL Server 2008
#include<stdio.h>
class A { public: int a;};
class B: public A {
public:
static int b;
B(){
b++;
printf("B:%d\n",b);
}
};
int main() {
A* a1 = new B[100];
A* a2 = new B();
return 0;
}
Error:
In function `main':
undefined reference to `B::b'
undefined reference to `B::b'
undefined reference to `B::b'
undefined reference to `B::b'
I was wondering if its possible to change the default "program" class that gets created for any console application to a partial class.
I want to do this because I want better organisation rather than have all methods in 1 file categorized by region. It would make more sense for me to have certain method categories sitting in separate files.
My understanding of a partial class is that it is a class definition in multiple files that during a compile merges the class files into 1 class unit.
I could be wrong, or there could be a better way for me to achieve better organisational structure. Any suggestions would help, and thanks
Hi everyone!
Out of curiosity about reverse engineering, I am thinking of writing a simple program (in C++) that takes an executable as input and produces the names of all the functions that were a part of source program of that executable.
Any pointers on how should I go about it?
Step-by-step approach would be much appreciated!
#include<stdio.h>
#include<math.h>
int main ()
{
FILE *fp;
fp=fopen("output","w");
float t,y=0,x=0,e=5,f=1,w=1;
for (t=0;t<10;t=t+0.01)
{
if( y==inf && y== nan)
break;
fprintf(fp,"%lf\t%lf\n",y,x);
y = y + ((e*(1 - x*x)*y) - x + f*cos(w*t))*t;
x = x + y*t;
}
return (0);
}
why is the ouput giving infinite and NAN values?
Imagine you got a class like this:
class Foo {
string key;
int value;
}
How would you select the Foo with the highest value from an IEnumeralbe<Foo>?
A basic problem is to keep the number of iterations low (i.e. at 1), but that affects readability. After all, the best I could find was something along the lines of this:
IEnumerable<Foo> list;
Foo max = list.Aggregate ((l, r) => l.value > r.value ? l : r);
Can you think of a more better way?
In Java, I want to download some data asynchronously in a Thread (or Runnable) object, and have the Thread put it's data into an Object I've declared within my main Thread.
How could I do this please?
I have 40+ TextViews and I want to add click events on them, but I try to do it "shortly" :
final GridLayout myGL;
myGL = (GridLayout) v0725.findViewById( R.id.tab1 );
for( int i = 0; i < myGL.getChildCount(); i++ )
if ( getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId()).indexOf("v")==0 ) {
((TextView) myGL.getChildAt(i)).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Log.v("edf", getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId()));
}
});
};
But Eclipse stops me on the Log.v line, because i should be final (but I can't)
any tips?
I need to generate a string of 7 chars that is based on the id of the row. So knowing the id of the image and a secret key, i should get the generated string.
the string must contain chars from "a" to "z" and numbers from 0 to 9.
I have a dir that contains photos like this
dir/p3/i2/s21/thumb.jpg
the generated string is p3i2s21, then is used to calculate the path of the image.
i want to upload an excel file from the client to the server using asp .then it shud check the field name of the file with the oracle database table and then save its content in the database.
can somebody help me with this....??
I am developing a c++ banking system.
I am able to get the float, newbal, values correctly and when I try to write to file, there is no data in the file.
else
{
file>>firstname>>lastname;
cout<<endl<<firstname<<" "<<lastname<<endl;
cout<<"-----------------------------------\n";
string line;
while (getline(file, line))
{
//stringstream the getline for line string in file
istringstream iss(line);
if (iss >> date >> amount)
{
cout<<date<<"\t\t$"<<showpoint<<fixed<<setprecision(2)<<amount<<endl;
famount+=amount;
}
}
cout<<"Your balance is $"<<famount<<endl;
cout<<"How much would you like to deposit today: $";
cin>>amountinput;
float newbal=0;
newbal=(famount+=amountinput);
cout<<"\nYour new balance is: $"<<newbal<<".\n";
file<<date<<"\t\t"<<newbal; //***This should be writing to file
but it doesn't.
file.close();
The text file looks like this:
Tony Gaddis
05/24/12 100
05/30/12 300
07/01/12 -300
//Console Output looks like this
Tony Gaddis
05/24/12 100
05/30/12 300
07/01/12 -300
Your balance is: #1
How much wuld you like to deposit: #2
Your new balance is: #1 + #2
write to file
close file.
//exits to main loop::::
How can I make it write to file and save it, and why is this happening.
I tried doing it with ostringstream as well considering how I used istringstream for the input. But it didn't work either :\
float newbal=0;
newbal=(famount+=amountinput);
ostringstream oss(newbal);
oss<<date<<"\t\t"<<newbal;
I am trying to self teach c++ so any relevant information would be kindly appreciated.
I would like to embed videos and have managed to to do so by manually coding the url in where needed. If my url is stored in <%= @vid.url %, how can I use that string for the value and src parameter?
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/videos/abc123"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/videos/abc123" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
Where do you get the best in-depth information for C# programming? I'm looking for tutorials, examples, blogs, specialized forums etc. dedicated to c#.
What is the "computer science" term for the practice of assigning a special meaning to one of a type's values. For example a numeric variable called "amount_to_transfer" where the special value "0" means "entire account balance" or a date value "spouse_date_of_birth" where "1/1/1800" means "unmarried".
I happen to feel that this is quite a bad "smell", but I'd like to have a name for it, and if possible, some blog post or article about why it's bad and how to fix it.
I have a few string problems that I need to put together for a complete homework assignment. They all work correctly by themselves, but when I put them together in the main function, the last one that finds the smallest word in a string gives an error. Anyone know why?
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
//Length of Word
String word1 = sc.next();
System.out.println(word1.length());
//Evens in one string odds in the other
String word2 = sc.next();
StringBuilder even = new StringBuilder();
StringBuilder odd = new StringBuilder();
for(int i = 0; i < word2.length(); i++){
if(i % 2 == 0){
even.append(word2.charAt(i));
}
else{
odd.append(word2.charAt(i));
}
}
System.out.println(even + " " + odd);
//Diminishing Suffix
String word3 = sc.next();
for(int j = 0; j < word3.length(); j++){
System.out.print(word3.substring(j, word3.length()) + " ");
}
System.out.printf("\n");
//Letter Replacement
String word4 = sc.next();
String word5 = sc.next();
String word6 = sc.next();
String word7 = word4.replace(word5, word6);
System.out.println(word7);
//How many times x appears in xstring
String word8 = sc.next();
String word9 = sc.next();
int index = word8.indexOf(word9);
int count = 0;
while (index != -1) {
count++;
word8 = word8.substring(index + 1);
index = word8.indexOf(word9);
}
System.out.println(count);
System.out.println();
//Lexicographically smallest word
String Sentence = sc.nextLine();
String[] myWords = Sentence.split(" ");
int shortestLengths, shortestLocation;
shortestLengths=(myWords[1]).length();
shortestLocation=1;
for (int i = 1; i <myWords.length; i++) {
if ((myWords[i]).length() < shortestLengths) {
shortestLengths=(myWords[i]).length();
shortestLocation=i;
}
}
System.out.println(myWords[shortestLocation]);
}
}
Talking about the lexicographically smallest one
Given a generic type, including List, Nullable how do i get a generic name for C#?
var t = typeof(Nullable<DateTime>);
var s = t.GetGenericTypeDefinition().Name + "<" + t.GetGenericArguments()[0].Name + ">";
This yields
"Nullable`1<DateTime>"
, but i need
"Nullable<DateTime>"
.
Hi,
The title says it all. But I don't know if I should go for static methods, just a header, a class, or something else?
What would be best practice? But, I don't want to have an instance of a utility class.
I want to add functions like:
Uint32 MapRGB (int r, int g, int b);
const char* CopyString(const char* char);
// etc. You know: utility methods...
Hi,
I'm trying to make a jquery tooltip that appears when a user mouses over a link. In my case the link is using display:block style so that it covers a large area. It works perfectly in Chrome and Firefox but in Internet Explorer it doesn't work at all. The tooltip doesn't show, the browsers own tooltip shows etc... IE!!!!
http://pastebin.com/1kBaMujV
Any ideas? Got to love internet explorer...
Public Class A
{
public A()
{
system.out.println("con call");
}
static
{
system.out.println("static call");
}
{
system.out.println("ins call");
}
Public static void main(string[] args)
{
new A();
new A();
}