re: 我的程序人生[未登錄] 史傳紅 2007-01-24 14:00
樓主對(duì)軟件領(lǐng)域的涉足很廣泛,而且有點(diǎn)領(lǐng)域也很精深,是我學(xué)習(xí)的楷模啊。
re: 計(jì)算Int最大最小值 史傳紅 2006-12-04 09:24
很好。
re: 并行編程--MPI開發(fā)入門 史傳紅 2006-06-12 20:12
我現(xiàn)在也在搞這方面的研究,不過是在linux系統(tǒng)下,多多向你學(xué)習(xí)。
re: 五一就要回家嘍 史傳紅 2006-05-15 14:24
謝謝,我是吉林大學(xué)(朝陽校區(qū))畢業(yè)的。
謝謝大家的祝福.我是安徽六安市霍邱縣眾興鄉(xiāng)洪崗村中心隊(duì)人(夠詳細(xì)的吧,呵呵).
@小東
相信只要努力了,我們一定都會(huì)有所收獲的.此外我也算是一個(gè)比較幸運(yùn)的人而已.相信有很多朋友比我更努力,但是過得比我還艱難...
謝謝大家的鼓勵(lì),我會(huì)一直盡力努力下去的.
最好,就是你安裝一個(gè)電子郵件服務(wù)器軟件。這下,你想打多長時(shí)間,就打多長時(shí)間。
請(qǐng)問它和電子郵件服務(wù)器怎么聯(lián)系上的?如何設(shè)置?謝謝.
原因不是*this不能轉(zhuǎn)換成const vector3D&,而是常成員函數(shù)(double angle() const)不能調(diào)用 非 常成員函數(shù)(double dotP(const Vector3D& v1,const Vector3D& v2)),如果把dotp改成如下定義:double dotP(const Vector3D& v1,const Vector3D& v2) const.
問題就解決了.
re: 漫談函數(shù)的返回值 史傳紅 2006-05-03 23:01
@<font color="#FF00FF" >Stone Jiang
希望是這樣的.
re: 關(guān)于語句作用域 史傳紅 2006-05-03 10:30
是的,標(biāo)準(zhǔn)規(guī)定了for(int i=0;i<10;i++)中的i只在語句內(nèi)有效,可見。
我覺得用string時(shí)間快的原因可能跟這句:char *pc2= new char[len+1];
有關(guān)。庫在處理string時(shí)候可能有某種優(yōu)化,使得處理時(shí)間快些。也就是不同的系統(tǒng)在優(yōu)化 string str2=str; 的時(shí)候可能不一樣,所以windows系統(tǒng)沒有占到優(yōu)勢(shì)。
@flyingxu
由于我以前遇到這個(gè)問題沒有解決,現(xiàn)在看了深入淺出MFC這本書,總結(jié)出來的,你能給出一個(gè)好的結(jié)構(gòu)嗎?我的意思是說把文檔的數(shù)據(jù)在一個(gè)對(duì)話框中實(shí)時(shí)表現(xiàn)出來,謝謝。
re: c++程序員 常用工具集 史傳紅 2006-04-24 13:33
版本控制現(xiàn)在比較不錯(cuò)的是 svn.
@Stone Jiang
能把這篇文章貼出來嗎?我打開連接發(fā)現(xiàn)是好多主題。謝謝。
@roa420
我在Visual C++ 6.0中編譯的時(shí)候也出現(xiàn)過問題,我懷疑它對(duì)友元支持的不好。
建議你換一個(gè)編譯器試試看。
原來是我和標(biāo)準(zhǔn)模板庫的函數(shù)重名了。通過改成:
template <class T>
const T& my_max(const T& a,const T& b)
{
return a > b ? a : b;
}
const float f = my_max(1.5f,2.5f);
就沒有問題了。
看到了樓主的這篇文章,我試著改了一下,如下:希望大家一起加入討論。
#include <iostream>
using namespace std;
class Matrix
{
private:
int rows,columns;
int **pMatrix;
public:
Matrix(int rows = 3,int columns = 2);
Matrix(const Matrix &M);
~Matrix();
Matrix& operator=(const Matrix& M);
int GetRows() const;
int GetColumns() const;
void SetValue();
friend Matrix operator*(const Matrix& a,const Matrix& b);
friend ostream& operator<<(ostream& os,const Matrix& M);
};
int Matrix::GetRows() const { return rows;}
int Matrix::GetColumns() const { return columns;}
// 構(gòu)造函數(shù)
Matrix::Matrix(int x,int y)
{
rows = x;
columns = y;
//有的時(shí)候?yàn)榱丝紤]創(chuàng)建對(duì)象的效率,在使用的時(shí)候分配存儲(chǔ)空間,而不在構(gòu)造函數(shù)中分配
pMatrix = new int* [x];
for (int i = 0 ; i < x; i++ )
{
pMatrix[i] = new int[y];
for(int j = 0;j < y;j++) //初始化每個(gè)值為0
pMatrix[i][j] = 0;
}
}
// 析構(gòu)函數(shù)
Matrix::~Matrix()
{
for (int i = 0 ;i < rows;i ++ )
delete[] pMatrix[i];
delete[] pMatrix;
}
// 賦值函數(shù)
Matrix& Matrix::operator=(const Matrix& M)
{
if(this != &M)
{
for (int ii = 0 ;ii < rows;ii++ )
if(pMatrix[ii])
delete[] pMatrix[ii];
if(pMatrix)
delete[] pMatrix;
rows = M.rows;
columns = M.columns;
//分配存儲(chǔ)空間
pMatrix = new int* [rows];
for (int k = 0 ; k < rows; k++ )
pMatrix[k] = new int[columns];
for ( int i = 0 ; i < rows; i ++ )
for ( int j = 0 ; j < columns; j ++ )
pMatrix[i][j] = M.pMatrix[i][j];
}
return *this;
}
void Matrix::SetValue()
{
int i,j,value;
for ( i = 0 ; i < rows; i ++ )
{
for ( j = 0 ; j < columns; j ++ )
{
cout << " 第 " << i << " 行 " ;
cout << " 第 " << j << " 列: " ;
cin >> value;
cout << endl;
pMatrix[i][j] = value;
}
}
}
// 拷貝構(gòu)造函數(shù)
Matrix::Matrix(const Matrix& M)
{
rows = M.rows;
columns = M.columns;
//分配存儲(chǔ)空間
pMatrix = new int* [rows];
for (int k = 0 ; k < rows; k++ )
pMatrix[k] = new int[columns];
for ( int i = 0 ; i < rows; i ++ )
for ( int j = 0 ; j < columns; j ++ )
pMatrix[i][j] = M.pMatrix[i][j];
}
Matrix operator*(const Matrix& a,const Matrix& b)
{
if (a.columns == b.rows)
{
Matrix c(a.rows,b.columns);
for ( int i = 0 ;i < a.rows;i ++ )
{
for ( int j = 0 ;j < b.columns;j ++ )
{
for ( int columnIndex= 0 ;columnIndex < a.columns;columnIndex++ )
c.pMatrix[i][j] += a.pMatrix[i][columnIndex] * b.pMatrix[columnIndex][j];
}
}
return c;
}
else
return Matrix();
}
ostream& operator<<(ostream& os,const Matrix& M)
{
for (int i = 0;i < M.rows;i++ )
{
for (int j = 0;j < M.columns;j++ )
os << M.pMatrix[i][j] << " ";
os << endl;
}
return (os << endl);
}
// 主函數(shù)
void main()
{
Matrix Ma(3,2),Mb(2,2);
Ma.SetValue();
Mb.SetValue();
cout << Ma << endl;
cout << Mb << endl;
Matrix Mc = Ma * Mb;//拷貝構(gòu)造函數(shù)
cout << Mc << endl;
Mc = Mb; //=運(yùn)算符,即賦值函數(shù)
cout << Mb << endl;
}
我覺得在一臺(tái)機(jī)器上擁有兩個(gè)系統(tǒng),速度是相當(dāng)慢的,我深有體會(huì).我目前用的兩種方法,覺得效率挺高:
1.用putty這個(gè)軟件從windows登陸linux系統(tǒng),然后在windows里面用UltraEdit編寫源代碼.通過putty在linux系統(tǒng)編譯和執(zhí)行.
2.用BVRDE這個(gè)軟件就可以做到在windows下面做linux開發(fā),它只是一個(gè)IDE,所用的文件,編譯器和調(diào)試器等都在linux系統(tǒng)上面.下載網(wǎng)址:
http://bvrde.sourceforge.net/index.htm