- wxWidgets/QT
- ffmpeg
- boost libs
- skills
i hope it was helpfull
- wxWidgets/QT
- ffmpeg
- boost libs
- skills
i hope it was helpfull
if allData == []:
return False
else:
return allData
better:
if not allData:
return None
return allData
i didn't understand it to 100%, but you can convert number to string very easy with stringstream(http://www.cplusplus.com/reference/iostream/stringstream/)
use valgrind --leak-check=full it will tell you where you have a leak ;)
i think think make more sense:
#!/usr/bin/env python
# File: .py
# Author: shadytyrant@gmail.com
# Date: 2009-11-25
# Notes:
#--------------------------------------------
class LibraryManager():
def filter(self, *args, **kwargs):
""" Search by kwargs or args"""
pass
def add(self, *args, **kwargs):
""" Add by kwargs or args"""
pass
def remove(self, *args, **kwargs):
""" Remove by kwargs or args"""
pass
class Library:
self.manager = LibraryManager()
def __init__(self):
# Just for reference at this point
id = 'NULL'
seriesIndex = 1
title = ''
author = ''
genra = ['fiction', 'non-fiction', 'science fiction', 'technical', 'reference']
publisher = ''
this should help, is not the perfect ways, but it works:
#include <iostream>
#include <cstring>
using namespace std;
int main ( int argc, char *argv[] )
{
if(argc > 1){
if (strcmp(argv[1], "-d") == 0){
cout<<"yes, it works"<<endl;
}
else{
cout<<"no, it won't read the if statement"<<endl;
}
}
}
I think you should do this:
CPP
Node* List::at(int index)
{
Node *temp = head;
int i;
for(i = 0; i < index; ++i)
{
temp = temp->next;
}
return temp;
}
H
Node* at(int index);
Can you post your code? <<snip>>
#include <string>
will help :)
WinApi is nice but QT or wxWidgets are portable!
i think WinApi like MFC is old and obsolete!
i would use:
- std::queue
- instead of char sender[20],recipient[20],content[100],date[10]; -> std::string
- strcpy would obsolte with std:.string
- instead of:
void receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
cout<<"\nNo messages to receive.";
}
void receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
throw CNoMessageReceived("No messages to receive.");
}
or
eError receiveMessage(Que q)
{
Message m=q.remove();
if(strcmp(m.sender," ")!=0)
{
cout<<"\nDate: "<<m.getDate();
cout<<"\nFrom: "<<m.sender;
cout<<"\nTo: "<<m.recipient;
cout<<"\nContent:"<<m.content;
}
else
return ERR_NO_MSG_RCV;
}
- use & Reference
eError receiveMessage(Que q)
BETTER:
eError receiveMessage(Que &q)
- cout in class is always bad design, except your class method called "PrintDebugXYZ"
enough for today :)
"A?%%CNT1%%" should help
would't it be easier to use? :
string lastNames(std::list<string> name_list){
stringstream ss;
for(std::list<string>::const_iterator i = name_list.begin(); i != name_list.end(); i++){
ss << '"' << i->substr(0) << i->erase(i->find(',')) << '"' << " ";
}
return ss.str();
}
what exactly should come out, i need an example!
second:
public:
zeroPoly();
BETTER:
public:
int zeroPoly(); // return type is int!
int Polynomial::zeroPoly(){
return 0;
}
Hi, first if i use C++ i also use C++ tools, like:
instead of:
#define FALSE 0
#define TRUE 1
typedef short Boolean;
this:
//#define FALSE 0 // == false
//#define TRUE 1 // == true
//typedef short Boolean; // == bool
btw, to find sigv is very easy
compile with -g3 -O0 with gcc
run it
and load the core file with gdb:
gdb ./mybin core
after print where to see the stack trace
have fun ;)
instead of:
int *array;
int mysize;
should be:
int *m_pArray;
int m_nSize;
some people use:
int *_array;
int _size;
or
int *array_;
int size_;
kind of a sign that the variable belogs to the class ;)
Hi,
first of all you should use m_ for member variables and second C++ is NOT C, you should use vector or list you save the data and sort. Just an idea
But here the code twith out segv:
#include<iostream>
using namespace std;
class Heapsort
{
private:
int *array;
int mysize;
public:
explicit Heapsort(int);
~Heapsort();
void allocate_array(int a);
void destroy_array();
int percolate_down(int);
void heapify();
void sort();
void fill_array();
void print();
};
Heapsort::Heapsort(int a)
{
allocate_array(a);
}
Heapsort::~Heapsort()
{
destroy_array();
}
void Heapsort::allocate_array(int a)
{
mysize = a;
//int *array was WRONG! it coverted the array member variable!
array = new int[mysize];
cout << array << endl;
//array[NULL]; doesn't do anything
}
void Heapsort::destroy_array()
{
delete [] array;
}
void Heapsort::fill_array()
{
int i;
int tmp = 0;
cout << array << endl;
// i = 1 is not really want you want
for (i = 0; i < mysize; i++){
cout << "\nEnter a number: ";
cin >> tmp;
array[i] = 99;
}
print(); //This prints the array before Heapify.
}
int Heapsort::percolate_down(int r)
{
int t=0;
int c = 2*r;
while (r < mysize)
{
if ((c < mysize) && (array[c] < array[c+1]))
{
c++;
}
if (array[r] < array[c])
{
t = array[c];
array[c] = array[r];
array[r] = t;
r=c;
c=2*c;
print(); //prints the progress of the heapifying
}else{
break;
}
}
return (r);
}
void Heapsort::heapify()
{
int r = mysize/2;
for(; r > 0; r--){
percolate_down(r);
}
}
void Heapsort::sort()
{
int r; …